2

I want to display a jquery dialog under certain conditions when the text changes on a textbox which has a datepicker attached to it.

In my TextChanged event I call to a javascript function which should display the dialog

protected void txtPickupDate_TextChanged(object sender, EventArgs e) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "showInfo", "showDialog();", true); } 

Javascript on my aspx page is:

function showDialog() { $("#popInfo").dialog("open"); } 

Using firebug I see that the javascript function is fired but the dialog is never displayed. I put an asp button on the page calling the function onClientClick to test the function and it works perfectly.

I also tried a solution mentioned else where but still no luck:

$('#popInfo').parent().appendTo(jQuery("form:first")); 

I'm pretty sure that is has something to do with updatepanels or postbacks but it has me stumped. Greatly appreciate any help!

1
  • u can use ajax extensions with update panel why to go for JQuery Commented Feb 16, 2012 at 4:02

1 Answer 1

1

If you have configured your TextChanged event and when you debug it you can see it going in there, try thisTextChanged event instead:

protected void txtPickupDate_TextChanged(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this.Page, typeof(UpdatePanel), Guid.NewGuid().ToString(), "$(function(){$('#popInfo').dialog('open');});", true); } 

I am assuming you are using UpdatePanel with a ScriptManager.

Also look at AJAX Control Tool Kit and JQuery Autocomplete Plugin for other ways to call server side code.

Sign up to request clarification or add additional context in comments.

7 Comments

I'm not sure how all your code looks like now as in ASPX & ASPX.CS, but if the above function is getting hit every time you want it to get hit and its in a UpdatePanel, theoretically speaking it should work always and you should be able to see it at the end of the html in console in FiireBug. Can you please be a little more explanatory as to how every thing is now and some new code that you are using. Apologies in adavance but will have to get back to you in about 11hrs from this comment.
Also can you please tell me what you are trying to achieve, so you can think about other options like Ive suggested in my answer.
Please post some more code... Specially you ASPX code page, so I can try to run it on my side and see whats going on. Preferebly all of ur ASPX, I already have the event in question and I can work from there.
I moved all the code into a test page and it is all working correctly. Looks like the fact that it is a usercontrol might be the issue (apologies for not mentioning it sooner, wasn't aware it would cause problems). Have tried out the approach at syedgakbar.wordpress.com/2008/03/01/… but still no luck. Will keep plugging away at it but let me know if you still want me to post some more code now knowing it works on a test page. Cheers!
I think there are some linkage issue's you are having since it works as part of an entire page but not on a UserControl within a page. But if you dont succeed and get stuck get back to me with more code. BTW: Since it works as part of one page you might want to mark my answer as the aswer to your problem.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.