Hey Everyone,
I'm using the code the above and running into an error i can't quite figure out. Maybe its something simple or maybe it's something that can't be done. Not sure.
I created a user control (button) that references a javascript file like this:
string url = ResolveClientUrl("./Scripts/main.js");
function SubmitButton_Click(e) {
try {
var src = typeof (event) != 'undefined' ? event.srcElement : e.target;
var originalButtonText = src.value;
src.disabled = true;
src.value = 'Procesing...';
src.aspnet_onclick();
var isOk = typeof (Page_IsValid) != 'undefined' ? Page_IsValid : true;
src.disabled = isOk;
if (isOk == false)
src.value = originalButtonText;
}
catch (err) {
// handle error
src.value = originalButtonText;
src.disabled = false;
}
}
function SubmitButton_InitOnClick(id) {
var sb = document.getElementById(id);
sb.aspnet_onclick = sb.onclick;
sb.onclick = SubmitButton_Click;
}
The error that i am running into is this:
The buttons in the update panel work everytime without any problems. When i click a button in the update panel and then click a button outside the update panel it chockes on this line of the above javascript.
src.aspnet_onclick();
The value of aspnet_click() is 'SubmitButton_Click(e)'. This is incorrect which causes it to choke.
The value should be 'onclick(event)'
For some reason when click the button inside the update panel and then the button outside the update panel causes this javascript error but I am not sure why the aspnet_onclick() is incorrect.