473,320 Members | 2,177 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,320 software developers and data experts.

Client Side Submit NOT Postback

How can I make a client-side javascript form.submit() look enough like a
postback that the browser back button will not show the previous state of
the form and instead go to the previous page?

I have two forms on the page. The first is a server form (runat=server) and
contains a Repeater control. One of the columns contains a checkbox for each
row.

The second form has a hidden field that will contain a comma delimited
string of the values of the checkboxes that are checked. A link on the page
runs the script that creates the string of values and assigns it to the
value of the hidden field and then calls the submit() of the second form. A
second hidden field in this non-server form is used to flag a form postback.

This works, however clicking back after submitting the (non-server) form
doesn't go back to the previous page only to the previous state of the
current page.

Here's a skeletal version of the code:
<form runat=server>
<asp:Repeater runat=server>
....
<input type=checkbox name=myValue runat=server
value='<%DataBinder.Eval(Container.DataItem, "myValue")%>'>
....
</asp:Repeater>
</form>
<form action="myPage.aspx" method="post" id="myForm" name="myForm">
<input type="hidden" name="hdnPostBack" id="hdnPostBack" runat=server
value="y">
<input type="hidden" name="myValue" id="myValue" value="" runat=server>
</form>
<script language=javascript>
function doSubmit()
{
// code to build comma delimited string of values strValues
document.forms["myForm"].myValue.value = strValues;
document.forms["myForm"].submit();
}
</script>
<a href="javascript:doSubmit()">submit it</a>

-------------------------------------------

Thanks,
Jim
Nov 18 '05 #1
2 4341
Hi Jim,

Just create a hidden input field. When you want to ignore any postback
stuff set the value to 1 and test for that otherwise treat it as a postback.
Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Jim Duncan" <so***@no.email> wrote in message
news:eG****************@TK2MSFTNGP12.phx.gbl...
How can I make a client-side javascript form.submit() look enough like a
postback that the browser back button will not show the previous state of
the form and instead go to the previous page?

I have two forms on the page. The first is a server form (runat=server) and contains a Repeater control. One of the columns contains a checkbox for each row.

The second form has a hidden field that will contain a comma delimited
string of the values of the checkboxes that are checked. A link on the page runs the script that creates the string of values and assigns it to the
value of the hidden field and then calls the submit() of the second form. A second hidden field in this non-server form is used to flag a form postback.
This works, however clicking back after submitting the (non-server) form
doesn't go back to the previous page only to the previous state of the
current page.

Here's a skeletal version of the code:
<form runat=server>
<asp:Repeater runat=server>
...
<input type=checkbox name=myValue runat=server
value='<%DataBinder.Eval(Container.DataItem, "myValue")%>'>
...
</asp:Repeater>
</form>
<form action="myPage.aspx" method="post" id="myForm" name="myForm">
<input type="hidden" name="hdnPostBack" id="hdnPostBack" runat=server
value="y">
<input type="hidden" name="myValue" id="myValue" value="" runat=server>
</form>
<script language=javascript>
function doSubmit()
{
// code to build comma delimited string of values strValues
document.forms["myForm"].myValue.value = strValues;
document.forms["myForm"].submit();
}
</script>
<a href="javascript:doSubmit()">submit it</a>

-------------------------------------------

Thanks,
Jim

Nov 18 '05 #2
Thanks, Ken.

I think the problem though is that I WANT it to be considered a postback but
it isn't. Probably because it's coming from a form that is not runat=server.

In other words, the SmartNavigation type stuff is not working. Clicking back
after a submit reloads the form instead of going to the previous page.

Thanks again,
Jim
"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:u2***************@TK2MSFTNGP12.phx.gbl...
Hi Jim,

Just create a hidden input field. When you want to ignore any postback
stuff set the value to 1 and test for that otherwise treat it as a
postback.
Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Jim Duncan" <so***@no.email> wrote in message
news:eG****************@TK2MSFTNGP12.phx.gbl...
How can I make a client-side javascript form.submit() look enough like a
postback that the browser back button will not show the previous state of
the form and instead go to the previous page?

I have two forms on the page. The first is a server form (runat=server)

and
contains a Repeater control. One of the columns contains a checkbox for

each
row.

The second form has a hidden field that will contain a comma delimited
string of the values of the checkboxes that are checked. A link on the

page
runs the script that creates the string of values and assigns it to the
value of the hidden field and then calls the submit() of the second form.

A
second hidden field in this non-server form is used to flag a form

postback.

This works, however clicking back after submitting the (non-server) form
doesn't go back to the previous page only to the previous state of the
current page.

Here's a skeletal version of the code:
<form runat=server>
<asp:Repeater runat=server>
...
<input type=checkbox name=myValue runat=server
value='<%DataBinder.Eval(Container.DataItem, "myValue")%>'>
...
</asp:Repeater>
</form>
<form action="myPage.aspx" method="post" id="myForm" name="myForm">
<input type="hidden" name="hdnPostBack" id="hdnPostBack" runat=server
value="y">
<input type="hidden" name="myValue" id="myValue" value="" runat=server>
</form>
<script language=javascript>
function doSubmit()
{
// code to build comma delimited string of values strValues
document.forms["myForm"].myValue.value = strValues;
document.forms["myForm"].submit();
}
</script>
<a href="javascript:doSubmit()">submit it</a>

-------------------------------------------

Thanks,
Jim


Nov 18 '05 #3

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

Similar topics

2
by: Rick Strahl [MVP] | last post by:
Run into an interesting problem today with a client of mine: They have an ASP.Net form that they want to drive through a client side HTTP interface. I know a Web Service would be a better way to...
1
by: Craig | last post by:
Hi I have a html table with an <td runat=server ...> element. On the onclick event of the <td> I want to do a postback, executing a server side function. What's the best way of doing this? The...
5
by: Jerry Camel | last post by:
Trying to implement the following: Users is logging in They enter theire username and password and click a login button The page should then display an activity indicator (animated gif) and then...
10
by: Ben | last post by:
Hi, I made an application in classic asp (reservation of books and video stuffs for students) and want to migrate to asp.net. The user has to chose a date, then pushung on a submit button. The...
2
by: Stuart Whiteford | last post by:
Hi, I asked this back in January without answer and forgot about it until now. I've got a basic web form, two textboxes, a couple of radio button groups, some required field validators, and a...
4
by: darrel | last post by:
This is a follow-up to a question I had yesterday. Quick summary: our intranet server dies a month or so ago and we had to get a new one up and running quickly. Any .net app that ran on the...
6
by: Steve Ryan | last post by:
can anyone send me to some good examples of edit in place for data frid columns i see dot net let me assign a control in the IDE any good sources of reading on editing columns with controls...
3
by: Joh | last post by:
I have a vb.net application where I have a client side html input: <td><input name="CurrentUserStatus" type="text" id="UserStatus" /></ td> Is there anyway I can acces the value of this control...
8
by: MAX2006 | last post by:
Hi, I am doing some client side javascipt work. I have a handler for window.onUnload event and within the code; I need to know the name of the asp.net button caused the postback. How can I do...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
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...
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

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.