ctl00_....._btnSave and the getElementById returns a null value. When I do the same thing in a non RadWindow, everything works fine. Please help me solve this issue.
The rad popup window:
function ShowInsertForm(url, width, height, idName, idValue) {
var extUrl = [url, "?" + idName + "=", idValue];
var oWnd = window.radopen(extUrl.join(""));
oWnd.setSize(width, height);
oWnd.set_modal(true);
oWnd.set_visibleStatusbar(false);
oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close);
return false;
}
This popup window has a Save and a Cancel buttons. When the user makes changes to the form and clicks the Cancel button, I need to display a javascript message to allow the user to confirm whether s/he wants to save the changes. if the answer is "YES", I want to execute the click event of the Save button. Here how I proceed:
In the code behind:
Protected Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
If _presenter.IsDataChanged(Me.GetUserData()) Then
InjectScript.Text = "<script type='text/javascript'>askquestion('" & btnSave.ClientID & "')</script>"
Else
InjectScript.Text = "<script type='text/javascript'>CancelEdit()</script>"
End If
End Sub
In the Aspx code:
function askquestion() {
if (confirm("Data has changed. Do you want to save the changes?")) {
document.getElementById('<%=btnSave.ClientID %>').click();
}
else {
CancelEdit();
}
return false;
}
Thank you in advance.
Masterdom5