Reputation: 12821
I'm moving my search functionality into a jquery dialog.
Originally I had
Use the following search box to located by Last Name
Search By: Search
I've added the following javascript :
var dlgSearch = $("#SearchDialog").dialog({
autoOpen: false,
zIndex: 9999,
bgiframe: true,
resizable: false,
width: 450,
modal: true,
overlay: {
backgroundColor: '#000',
opacity: 0.5
},
buttons: {
'Search':
function() {
<%= Page.ClientScript.GetPostBackEventReference(btnSearch, String.Empty) %>;
},
Cancel: function() {
$(this).dialog('close');
}
}
});
dlgSearch.parent().appendTo($("form:first"));
This works fine. However Now I rendering 2 search buttons to the browser. the original one rendered with the tag, and the button rendered with the jquery dialog instantiation. I'd like to get rid of the one rendered with the server side tag and only use the jquery one.
The problem is, if I remove the tag, I get a compile error at the GetPostBackEventReference call because the control btnSearch no longer exists.
I could alway style the btnSearch with CSS and make it display:none, but that just seems like a dirty way to address the problem.
Isn't there a way to call a server side method without it being tied to a controls event? Be aware that I don't want an ajax callback approach, I need to actually have a postback.
Upvotes: 1
Views: 925
Reputation: 22448
use this on client: __doPostBack("SearchDialog", "");
and this on server:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack && Request.Form["__EVENTTARGET"] == "SearchDialog")
{
//your code here
}
}
Upvotes: 1