H
Harry
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.getElementById("ins").action="thispage.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:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Provider = ... ; Data Source =...;">
</asp:SqlDataSource>
<asp:HiddenField ID="HiddenField1" runat="server" />
</form>
<form id="ins" style="width:750px;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="sendtodb()"/>
</form>
<script language="javascript" type="text/javascript">
function sendtodb()
{
var nfieldout=document.getElementById("hiddenfield1").value
......
......
document.getElementById("sql").value=inscomm
document.getElementById("conn").value=conn
document.getElementById("ins").action="thispage.aspx"
document.getElementById("ins").submit()
return true;
</script>
code-behind
-----------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Dim conn, sql
sql = Request.Form("sql")
conn = Request.Form("conn")
Dim oConnection As OleDbConnection
Dim sConnection As String
oConnection = New OleDbConnection()
Dim comd As OleDbCommand
sConnection = conn
oConnection.ConnectionString = sConnection
oConnection.Open()
comd = New OleDbCommand(sql, oConnection)
comd.ExecuteNonQuery()
oConnection.Close()
else
HiddenField1.Value = "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.getElementById("ins").action="thispage.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:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Provider = ... ; Data Source =...;">
</asp:SqlDataSource>
<asp:HiddenField ID="HiddenField1" runat="server" />
</form>
<form id="ins" style="width:750px;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="sendtodb()"/>
</form>
<script language="javascript" type="text/javascript">
function sendtodb()
{
var nfieldout=document.getElementById("hiddenfield1").value
......
......
document.getElementById("sql").value=inscomm
document.getElementById("conn").value=conn
document.getElementById("ins").action="thispage.aspx"
document.getElementById("ins").submit()
return true;
</script>
code-behind
-----------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Dim conn, sql
sql = Request.Form("sql")
conn = Request.Form("conn")
Dim oConnection As OleDbConnection
Dim sConnection As String
oConnection = New OleDbConnection()
Dim comd As OleDbCommand
sConnection = conn
oConnection.ConnectionString = sConnection
oConnection.Open()
comd = New OleDbCommand(sql, oConnection)
comd.ExecuteNonQuery()
oConnection.Close()
else
HiddenField1.Value = "1"
.......
.......
end if
end sub