Josh Gough

<May 2008>
SuMoTuWeThFrSa
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567


Navigation

Subscriptions

Post Categories



__doPostBack and the empty second parameter? How to manually set it?

Is it possible to manually specify the second parameter in a __doPostBack handler?

I have this code:
                   
                        Text="Test of Server Side Link Button"
                        CommandName="Action"
                        CommandArgument="$1"                      
                    />
The rendered code looks like this:

            BLOCKED SCRIPT__doPostBack('ctl00$ctl00$ctlPagePlaceHolder$blah$blah$actTestServerSide','')

That second parameter is empty though!

I need to be able to have code on the _client side_ replace the $1 with a value of my choice before the actual link gets submitted. The reason for this is that I have a GridView with 100 items in it, and I pass down one static block of HTML code as a client-side template for a context menu that operates on the line item of each GridViewRow instance. I then have a click handler which does something like:
onclick="ContextMenu_Place(event,'ctlPathGoesHere$blah$blah$blah','ctl00Path$blah$blah',[],['189884','44394743']);
The ContextMenu_Place function copies the template code and then uses the values of the second array to replace the placeholders. The first array, empty here, specifies the css class name of rows in the menu that need to be grayed out.

The static block looks like this when rendered to the client side:
    <table id="blah_blah_table" border="0" cellpadding="0" cellspacing="0" class="ActionsContextMenuContainer">
 <tr valign="top">
<td>
<div id="blah$blah">
<div class="actContact"><a title="Contact" href="/Contact.aspx?Item=$1">Contacta>div>
<div class="actPay"><a title="Pay" href="/Pay.aspx?Item=$1">Paya>div>
<div class="actTestServerSide">
<a id="blah$blah$actTestServerSide"
href
="BLOCKED SCRIPT__doPostBack('$blah$blah$actTestServerSide','')">Test of Server Side Link Buttona>
div>
div>
        td>
tr>
table>

In the first two cases, the links are to external pages, not POSTBACKS. But in the last case, the action should be POSTBACK, so I need that last line to read:

href="BLOCKED SCRIPT__doPostBack('$blah$blah$blah','$1')">Test of Server Side Link Buttona>

This will enable me to use my client side templating function to replace the argument with the actual line item ID.

But, I can't figure out how to get that second parameter of __doPostBack to be non-blank.

Anyone have any ideas?

Thanks

------
Update

I read about the Page.ClientScript.GetPostBackEventRefernce method.
This let me accomplish what I need, even though trying to set a parameter with it still failed. I ended up creating a hidden field, a hidden button with a server side event handler. I made the postback target that button, and then read the hidden field's value in the event handler after manually setting the value through the JS href prior to the call to __doPostBack:

... <div class="actTestServerSide"> <a title="Send the id to the server side">').value = '$1'; ;">Send to Server Side</a> </div>

posted on Wednesday, September 20, 2006 11:33 AM by JoshuaGough





Powered by Dot Net Junkies, by Telligent Systems