I have to do this so often, I wrote a set of server controls to help. I've
uploaded them to GotDotNet, so in a few days you should be able to find them
there.
Assuming that you have added a client side handler for the click event to a
normal control (which is what I do in the library), the postback will occur
based on whether you return true or false from the onclick event. If you
return false, it will not postback. If you return true, it will postback.
An example:
'Building Client side window attributes with width and height.
'the the window will be positioned to the middle of the screen
windowAttribs = "dialogHeight:" & _dialogHeight & "px;" & _
"dialogWidth:" & _dialogWidth & "px;" & _
"left:'+((screen.width -" & _dialogWidth & ") /
2)+';" & _
"top:'+ (screen.height - " & _dialogHeight & ")
/ 2+';" & _
"edge:Sunken; status:0;" & _
"resizable:0;Help:No;"
'Building the client script- window.open, with additional
parameters
'having return true; at the end of this line is what allows the
web control's
'server side click event still fire
clientScript = "rsc_getObj(""" & Me.UniqueID &
"_DIALOGRETURNVALUE" & """).value=window.showModalDialog(""" & _pagePath &
""",""" & _windowName & """,""" & windowAttribs & """);if(rsc_getObj(""" &
Me.UniqueID & "_DIALOGRETURNVALUE" & """).value!=""0"" & rsc_getObj(""" &
Me.UniqueID & "_DIALOGRETURNVALUE" & """).value!=""undefined""){return
true;}else{return false;}"
"SkeanDu" wrote:
Ok, here is my problem.
I have an aspx page that displays a databound datagrid and in one of
the datagrid column headers I have an image that when clicked opens up
a modal web dialog (another aspx page).
From this dialog I want the users to be able to select a filter item
from a databound combobox and click on the apply button on the web
dialog that will then disappear and the filtered data will be displayed
on my datagrid.
Now here is the problem: How can I force a postback on the original
aspx page containing the datagrid so that only the filtered data is
displayed? Basically I want to pass back the selected cobobox item from
the web dialog to the calling window and then use that data to filter
my dataset and rebind to the datagrid.
I've thought about using hidden input fields on the datagrid page and
populating them when the user clicks the apply button on the web
dialog. But how do I then fire a postback to rebind my datagrid? Is
there a way to fire the postback on the datagrid page when the user
clicks the apply button on the web dialog page? The way I'm going about
it just now involves mainly client side java script but I am sure there
must be a way to do this server side?
Anyway, if anyone has any pointers I would be very grateful.
Thanks,
Vincent