Jfb1126
asked on
javascript does not run properly when called from ASP:Button object
I am calling a javascript object from an ASP button using OnClientClick. the javascript gets called (added an alert to test) but does not run... the funny thing is if a create an html input button, the script runs as expected.
here are the buttons...
I don't understand why it would work with one control and not the other.
here are the buttons...
<asp:Button runat ="server" ID="btnLookupCustomer" Visible="true" Text="Lookup Customer" Enabled="false" OnClientClick="openPopUp();" />
<input type="button" id="test" value="Lookup Customer1" onclick="openPopUp();" />
and the javascript... function openPopUp() {
alert("i'm here");
TINY.box.show({ iframe: "CustomerSelectPopup.aspx", close: true, width: 700, height: 600 });
}
I don't understand why it would work with one control and not the other.
I'm not a .NET dev but your asp code runs on the server before the page loads. Your javascript runs on the client, after the page loads.
The best thing to do is to have the experts look at your rendered page. Get your page on a public link. If you are working locally, then just get the sample page somewhere public where it can be seen. You can also render the html and place the html, css and javascript on jsbin.com or other playground.
More than likely you have a javascript error that is preventing this from working or the supporting files for the pop up are not loaded correctly, or you don't have your js code in a ready function. It is hard to tell without seeing the full page.
http://sandbox.scriptiny.com/tinybox/
The best thing to do is to have the experts look at your rendered page. Get your page on a public link. If you are working locally, then just get the sample page somewhere public where it can be seen. You can also render the html and place the html, css and javascript on jsbin.com or other playground.
More than likely you have a javascript error that is preventing this from working or the supporting files for the pop up are not loaded correctly, or you don't have your js code in a ready function. It is hard to tell without seeing the full page.
http://sandbox.scriptiny.com/tinybox/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As julianH wrote, return false from the code to prevent the button from submitting the form.
UseSubmitBehavior is not used to prevent a postback, only to change how the postback is done.
UseSubmitBehavior is not used to prevent a postback, only to change how the postback is done.
ASKER
adding the return to the call worked.
thank you,
thank you,
You are welcome - thanks for the points - good luck with your project.
ASKER