473,383 Members | 1,862 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,383 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 1677
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: 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. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.