Hi,
This aspx page (let's call it thispage.aspx) fetches data from a
sqldatasource, then performs several things (in code-behind) and, to
simplify, passes data from code-behind via a hiddenfield to a javascript in
the aspx file. This javascript performs things and finally send data via a
form to another database.
My problem is that when the page is postback (with this java-line:
document.getEle mentById("ins") .action="thispa ge.aspx"), instead of
performing the code after "If Page.IsPostBack Then", it shows the original
aspx file again.
Any idea what i have to change to do what i want to do?
Thanks
Harry
aspx file:
-------
<form id="form1" runat="server">
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="Provider = ... ; Data Source =...;">
</asp:SqlDataSour ce>
<asp:HiddenFiel d ID="HiddenField 1" runat="server" />
</form>
<form id="ins" style="width:75 0px;background-color:Gray" method="post">
<input id="sql" name="sql" type="hidden" />
<input id="conn" name="conn" type="hidden" />
<input runat="server" id="Submit1" type="button" value="Klik hier om
te bewaren" onclick="sendto db()"/>
</form>
<script language="javas cript" type="text/javascript">
function sendtodb()
{
var nfieldout=docum ent.getElementB yId("hiddenfiel d1").value
......
......
document.getEle mentById("sql") .value=inscomm
document.getEle mentById("conn" ).value=conn
document.getEle mentById("ins") .action="thispa ge.aspx"
document.getEle mentById("ins") .submit()
return true;
</script>
code-behind
-----------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
If Page.IsPostBack Then
Dim conn, sql
sql = Request.Form("s ql")
conn = Request.Form("c onn")
Dim oConnection As OleDbConnection
Dim sConnection As String
oConnection = New OleDbConnection ()
Dim comd As OleDbCommand
sConnection = conn
oConnection.Con nectionString = sConnection
oConnection.Ope n()
comd = New OleDbCommand(sq l, oConnection)
comd.ExecuteNon Query()
oConnection.Clo se()
else
HiddenField1.Va lue = "1"
.......
.......
end if
end sub
This aspx page (let's call it thispage.aspx) fetches data from a
sqldatasource, then performs several things (in code-behind) and, to
simplify, passes data from code-behind via a hiddenfield to a javascript in
the aspx file. This javascript performs things and finally send data via a
form to another database.
My problem is that when the page is postback (with this java-line:
document.getEle mentById("ins") .action="thispa ge.aspx"), instead of
performing the code after "If Page.IsPostBack Then", it shows the original
aspx file again.
Any idea what i have to change to do what i want to do?
Thanks
Harry
aspx file:
-------
<form id="form1" runat="server">
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="Provider = ... ; Data Source =...;">
</asp:SqlDataSour ce>
<asp:HiddenFiel d ID="HiddenField 1" runat="server" />
</form>
<form id="ins" style="width:75 0px;background-color:Gray" method="post">
<input id="sql" name="sql" type="hidden" />
<input id="conn" name="conn" type="hidden" />
<input runat="server" id="Submit1" type="button" value="Klik hier om
te bewaren" onclick="sendto db()"/>
</form>
<script language="javas cript" type="text/javascript">
function sendtodb()
{
var nfieldout=docum ent.getElementB yId("hiddenfiel d1").value
......
......
document.getEle mentById("sql") .value=inscomm
document.getEle mentById("conn" ).value=conn
document.getEle mentById("ins") .action="thispa ge.aspx"
document.getEle mentById("ins") .submit()
return true;
</script>
code-behind
-----------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
If Page.IsPostBack Then
Dim conn, sql
sql = Request.Form("s ql")
conn = Request.Form("c onn")
Dim oConnection As OleDbConnection
Dim sConnection As String
oConnection = New OleDbConnection ()
Dim comd As OleDbCommand
sConnection = conn
oConnection.Con nectionString = sConnection
oConnection.Ope n()
comd = New OleDbCommand(sq l, oConnection)
comd.ExecuteNon Query()
oConnection.Clo se()
else
HiddenField1.Va lue = "1"
.......
.......
end if
end sub
Comment