Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Client Side Submit NOT Postback

Reply
Thread Tools

Client Side Submit NOT Postback

 
 
Jim Duncan
Guest
Posts: n/a
 
      10-22-2004
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


 
Reply With Quote
 
 
 
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      10-22-2004
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" <(E-Mail Removed)> wrote in message
news:eGZ2sE%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Jim Duncan
Guest
Posts: n/a
 
      10-22-2004
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." <(E-Mail Removed)> wrote in message
news:u2wjTn%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:eGZ2sE%(E-Mail Removed)...
>> 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
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute client-side code _after_ client-side validation? Bogdan ASP .Net 2 06-09-2008 01:31 PM
Client side script after client side validation with asp.net 2.0 Boss302 ASP .Net 0 11-21-2006 08:43 AM
ListBox items changed client-side are not available server-side Valerian John ASP .Net 6 05-17-2004 06:45 PM
Client Side changes not refecting server side label =?Utf-8?B?U3Jpbmk=?= ASP .Net 3 02-21-2004 04:56 AM
Adding custom client-side onClick handler with client-side validator controls Zoe Hart ASP .Net Web Controls 1 01-08-2004 10:45 PM



Advertisments