M
Mei leng Leong
HI kindly helper,
i'm facing a problem with javascript rendering from code-behind. i'm
prompt a confirmation message to client. Would like to get response from
client. then will proceed further action depend on the response on the
client.
my coding is
<script language=javascript>
function __doPostBack(eventTarget, eventArgument)
{
var theform = document.Form1;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<!-- Add two hidden variables used in __doPostBack-->
<input type="hidden" name="__EVENTTARGET">
<input type="hidden" name="__EVENTARGUMENT">
<asp:TextBox ID="txt1" Runat="server"></asp:TextBox>
<asp:Button ID="btnsubmit" Runat="server" text="submit"></asp:Button>
<asp:Button ID="hiddenbtn" Runat="server" Visible="False"></asp:Button>
</form>
========================================>
Code behind
Private Sub btnsubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnsubmit.Click
Dim errmsg As String
errmsg = "<script language=javascript>" & Chr(13)
errmsg += "if (confirm(""record exist. To Continue!""))" & Chr(13)
errmsg += " __doPostBack('hiddenbtn','');" & Chr(13)
' errmsg += Chr(13)
' errmsg += " function fndoPostBack2(eventTarget, eventArgument) " &
Chr(13)
' errmsg += "{" & Chr(13)
'errmsg += " var theform = document.Form1;" & Chr(13)
'errmsg += " theform.__EVENTTARGET.value = eventTarget;" & Chr(13)
'errmsg += " theform.__EVENTARGUMENT.value = eventArgument;" & Chr(13)
'errmsg += " theform.submit();" & Chr(13)
errmsg += " }" & Chr(13)
errmsg += "</script>"
Response.Write(errmsg)
End Sub
===========================>
My question:
1.when i render the javascript function fndopostback2 together will give
me __EVENTARGUMENT is null
2.if i only render the javascript confirm the __doPostback error
message is object expected form javascript.
is anybody have idea to solve this or any suggestion to do this. thank
you very much.
i'm facing a problem with javascript rendering from code-behind. i'm
prompt a confirmation message to client. Would like to get response from
client. then will proceed further action depend on the response on the
client.
my coding is
<script language=javascript>
function __doPostBack(eventTarget, eventArgument)
{
var theform = document.Form1;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<!-- Add two hidden variables used in __doPostBack-->
<input type="hidden" name="__EVENTTARGET">
<input type="hidden" name="__EVENTARGUMENT">
<asp:TextBox ID="txt1" Runat="server"></asp:TextBox>
<asp:Button ID="btnsubmit" Runat="server" text="submit"></asp:Button>
<asp:Button ID="hiddenbtn" Runat="server" Visible="False"></asp:Button>
</form>
========================================>
Code behind
Private Sub btnsubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnsubmit.Click
Dim errmsg As String
errmsg = "<script language=javascript>" & Chr(13)
errmsg += "if (confirm(""record exist. To Continue!""))" & Chr(13)
errmsg += " __doPostBack('hiddenbtn','');" & Chr(13)
' errmsg += Chr(13)
' errmsg += " function fndoPostBack2(eventTarget, eventArgument) " &
Chr(13)
' errmsg += "{" & Chr(13)
'errmsg += " var theform = document.Form1;" & Chr(13)
'errmsg += " theform.__EVENTTARGET.value = eventTarget;" & Chr(13)
'errmsg += " theform.__EVENTARGUMENT.value = eventArgument;" & Chr(13)
'errmsg += " theform.submit();" & Chr(13)
errmsg += " }" & Chr(13)
errmsg += "</script>"
Response.Write(errmsg)
End Sub
===========================>
My question:
1.when i render the javascript function fndopostback2 together will give
me __EVENTARGUMENT is null
2.if i only render the javascript confirm the __doPostback error
message is object expected form javascript.
is anybody have idea to solve this or any suggestion to do this. thank
you very much.