Using jQuery UI's modal dialog inside ASP.NET
Currently I have a project where I have a form in ASP.NET that needs a look up service. For example the input below wants a Customer ID, but maybe the user only knows the customers by name.
<input name="CustomerId" type="text" id="CustomerId" />
I'd like to use jQuery UI's modal dialog to append an image to the right of this input, which fires dialog("open")
containing the necessary code to look up a customer by name, returning the ID back to the form input upon closing the dialog. This is extremely similar functionality to the Datepicker's icon trigger found here: http://jqueryui.com/demos/datepicker/#icon-trigger
Right now, I have this javascript:
$("#CustomerId").dialog({
autoOpen: false,
modal: true,
draggable: false,
resizable: false,
buttons: {
Ok: function () {
$(this).dialog("close");
},
Cancel: function () {
$(this).dialog("close");
}
}
});
$("#CustomerId").click(function () {
$("#CustomerIdDialog").dialog("open");
return false;
});
I need to be able to pass the ID of the input element into jQuery, probably using the $(this) selector somehow. I'd like to be able to re-use the same code for multiple elements on the same form that require the customer ID look up. I also don't know how to create this kind of functionality inside the ASP.NET environment because it doesn't fundamentally allow more than one form inside one .aspx page.开发者_开发百科
Any help or guidance in the right direction is greatly appreciated!
something like $(this).text() or $(this).val() should do the trick.
better you make a usercontrol that can fire this modal popup. Depending upon the control the page can have multiple modal popups and only the requiredon will be fired up. But you need to fix that up in the code of that user control.
精彩评论