473,626 Members | 3,325 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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
Apr 23 '07 #1
4 1701
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.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
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.getEl ementByI("ins") .action="thispa ge.aspx") refers to itself
("thispage.aspx "). The whole code here below is contained in "thispage.a spx"
and "thispage.aspx. vb".
"Peter Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comschreef in
bericht news:60******** *************** ***********@mic rosoft.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
sqldatasourc e, 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.getEl ementById("ins" ).action="thisp age.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"
ConnectionStri ng="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.getEl ementById("sql" ).value=inscomm
document.getEl ementById("conn ").value=co nn
document.getEl ementById("ins" ).action="thisp age.aspx"
document.getEl ementById("ins" ).submit()
return true;
</script>
code-behind
-----------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventAr gs) 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.V alue = "1"
.......
.......
end if
end sub

Apr 23 '07 #3
IsPostBack just checks for the "__Viewstat e" 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.getEl ementByI("ins") .action="thispa ge.aspx") refers to itself
("thispage.aspx "). The whole code here below is contained in "thispage.a spx"
and "thispage.aspx. vb".
"Peter Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comschreef in
bericht news:60******** *************** ***********@mic rosoft.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.getE lementById("ins ").action="this page.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"
ConnectionStr ing="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.getE lementById("sql ").value=inscom m
document.getE lementById("con n").value=co nn
document.getE lementById("ins ").action="this page.aspx"
document.getE lementById("ins ").submit()
return true;
</script>
code-behind
-----------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventA rgs) 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. 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******** ********@TK2MSF TNGP04.phx.gbl. ..
IsPostBack just checks for the "__Viewstat e" 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.getE lementByI("ins" ).action="thisp age.aspx") refers to itself
("thispage.asp x"). The whole code here below is contained in
"thispage.aspx " and "thispage.aspx. vb".
"Peter Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comschreef in
bericht news:60******** *************** ***********@mic rosoft.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
sqldatasourc e, 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.get ElementById("in s").action="thi spage.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"
ConnectionSt ring="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.get ElementById("sq l").value=insco mm
document.get ElementById("co nn").value=co nn
document.get ElementById("in s").action="thi spage.aspx"
document.get ElementById("in s").submit()
return true;
</script>
code-behind
-----------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.Event Args) 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 .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
569
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 simple example will help. I created a simple web project that contains two simple forms ... WebForm1 and WebForm2. WebForm1 has a button which when clicked simply does a Response.Redirect("WebForm2.aspx"). When I run the program and click the...
0
951
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 when I have something inside the textbox. If I don't have the validator control on the webform, then the button clicked event gets fired (causing the postback - I have a breakpoint set in the Button.Clicked event of the button on the webform).
9
2444
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"); ucline.Initializecontrol(line,alternate); Placeholder1.Controls.Add(ucline); }
3
2571
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 a postback to occur which in turn triggers a sub in a user control... Error: Argument not specified for parameter e of Public Sub UploadDate(Sender As
6
2693
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 validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate
6
2849
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 order for a dynamically created control to persist its state, it needs to be created and loaded into the page control hierarchy before the viewstate is loaded. The proposed solution, and that which I have been using, has been to create all of...
4
1123
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 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"),...
2
4850
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 that button, I would like to show one small Pop-up window. Now , problem here is that , How to catch the event generated by the Image Button? Now , whenever I click on Image Button , some Server Error is shown,
2
1845
by: NannMaw | last post by:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Server Error in '/WebSite1' Application. -------------------------------------------------------------------------------- Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.