473,326 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

problem with postback

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.as px"), 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.as px"
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
Apr 23 '07 #1
4 1114
Harry,
From what you have written, it *sounds* like what you want to do is a
cross-page postback. Look up the term "cross-page postback" and you will find
examples and description of how to use.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Harry" wrote:
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.as px"), 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.as px"
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
Apr 23 '07 #2
Peter, thanks for replying.

Maybe my explanation was not good, but i don't think it's cross-page
postback, since the 'action' method in javascript of the form
(document.getElementByI("ins").action="thispage.as px") refers to itself
("thispage.aspx"). The whole code here below is contained in "thispage.aspx"
and "thispage.aspx.vb".
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comschreef in
bericht news:60**********************************@microsof t.com...
Harry,
From what you have written, it *sounds* like what you want to do is a
cross-page postback. Look up the term "cross-page postback" and you will
find
examples and description of how to use.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Harry" wrote:
>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.a spx"), 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.a spx"
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

Apr 23 '07 #3
IsPostBack just checks for the "__Viewstate" hidden field in the
postback form fields. as you are submitting a different form on the page
then the one containing the viewstate, the viewstate hidden field is not
included in the postback data
-- bruce (sqlwork.com)

Harry wrote:
Peter, thanks for replying.

Maybe my explanation was not good, but i don't think it's cross-page
postback, since the 'action' method in javascript of the form
(document.getElementByI("ins").action="thispage.as px") refers to itself
("thispage.aspx"). The whole code here below is contained in "thispage.aspx"
and "thispage.aspx.vb".
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comschreef in
bericht news:60**********************************@microsof t.com...
>Harry,
From what you have written, it *sounds* like what you want to do is a
cross-page postback. Look up the term "cross-page postback" and you will
find
examples and description of how to use.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Harry" wrote:
>>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

Apr 23 '07 #4
Thanks for the explanation.
Now, if you would have a solution in mind for that, it would be great.
"bruce barker" <no****@nospam.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
IsPostBack just checks for the "__Viewstate" hidden field in the postback
form fields. as you are submitting a different form on the page then the
one containing the viewstate, the viewstate hidden field is not included
in the postback data
-- bruce (sqlwork.com)

Harry wrote:
>Peter, thanks for replying.

Maybe my explanation was not good, but i don't think it's cross-page
postback, since the 'action' method in javascript of the form
(document.getElementByI("ins").action="thispage.a spx") refers to itself
("thispage.aspx"). The whole code here below is contained in
"thispage.aspx" and "thispage.aspx.vb".
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comschreef in
bericht news:60**********************************@microsof t.com...
>>Harry,
From what you have written, it *sounds* like what you want to do is a
cross-page postback. Look up the term "cross-page postback" and you will
find
examples and description of how to use.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Harry" wrote:

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
Apr 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: MrMike | last post by:
I have a datagrid containing a drop-down-list. The datagrid contains Edit,Update,Cancel buttons and respective events. Whenever I make a change to one particular field (a drop-down-list in...
5
by: fripper | last post by:
I posted this problem a couple of days ago but felt I might have better luck re-stating the problem. Apparently I messed up IIS (v. 5) somehow because I am suddenly unable to load web forms! A...
0
by: bill yeager | last post by:
I have a simple button and textbox on a webform with a RequiredFieldValidator tied to the textbox control. The problem is that a postback never occurs on the webform by clicking the button even...
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
3
by: Tim::.. | last post by:
Can someone please tell my why I get the following problem when I type the following piece of code! How do I get around this??? The idea is that when a user clicks a button on a form it causes...
6
by: | last post by:
Hi all, I have a bunch of dropdownlists that are populated in client-side javascript. When i do a postback I get the following error:- Invalid postback or callback argument. Event...
6
by: hlubocky | last post by:
I thought I had a good grasp of the problem related to dynamically creating controls, but it appears that as my application grew in complexity, the problem has resurfaced. As I understand it, in...
4
by: Harry | last post by:
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...
2
by: Simit Kulkarni | last post by:
Hi All, I am stucked with a problem , regarding Repeater Controls Header Template. I want to show a Image Button in the Header Template of a Repeater Control and on the Click of...
2
by: NannMaw | last post by:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Server Error in '/WebSite1' Application. -------------------------------------------------------------------------------- Invalid postback or callback argument. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.