well I have 2 pages page1 and page2
from page1 after clicking on grid button loads page2 as window
In page 2 I have 3 control: TextBox and 2 Button Save and Close
here is code below
<script type="text/javascript">
function returnToParent(result) {
var arg = new Object();
arg.result = result;
arg.text = document.getElementById("txtComment").value;
var wnd = GetRadWindow();
wnd.close(arg);
}
function GetRadWindow() {
var mwnd = null;
if (window.radWindow) mwnd = window.radWindow;
else if (window.frameElement.radWindow) mwnd =
window.frameElement.radWindow;
return mwnd;
}
</script>
<asp:TextBox ID="txtComment" TextMode="MultiLine" runat="server"
Width="700px" Height="60px" />
<asp:LinkButton ID="lnkSave" runat="server" Text="Save" Width="100%"
CssClass="white" onclick="lnkSave_Click" />
<asp:LinkButton ID="lnkClose" runat="server" Text="Close" Width="100%"
CssClass="white" CausesValidation="false"
OnClientClick="returnToParent(0); return false;" />
and Code Behind
protected void lnkSave_Click(object sender, EventArgs e) {
if(!string.IsNullOrEmpty(txtComment.Text))
{
ClientScript.RegisterStartupScript(this.GetType(),
"CloseWindow", "returnToParent(1)", true);
}
else {
ClientScript.RegisterStartupScript(this.GetType(),
"CloseWindow", "returnToParent(1)", true);
}
}
as you see close button I call javascript function
returnToParent(result) and set resalt 0
it warks and does not postback
now I want to do if TextBox.Text is empty that I check it in code behind
if(!string.IsNullOrEmpty(txtComment.Text))
if it's empty it goes to else statement there I try to do it so that not postback with registering script
but there is trouble when I click save button when textbox is empty it postbacks again
How can I do it that not postback?? :(