Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > ASP.Net > ASP.net Buttons


Reply
 
Thread Tools Display Modes
  #1  
Old 11-30-2006, 01:02 PM
netpicker9 netpicker9 is offline
Centurion
 
Join Date: Jun 2005
Posts: 127
Default ASP.net Buttons


HI,

I have 3 asp:button's in a page, two buttons are calling different other pages when they clicked and
one is to refresh the self page.
Begin.aspx:
Code:
'Lots of other stuff
<asp:button Id="doCheck" runat="server" text="Check" onClientClick="BeforeCheck()">
<asp:button Id="doRefresh" runat="server" text="Refresh">
<asp:button Id="doContinue" runat="server" text="Continue">
doCheck calls Begin.aspx with V=Y (I am passing this as query string)
dpRefresh calls Begin.aspx with V=N (or without V value)
doContinue calls Pickup.aspx

Code:
function BeforeCheck(){
  //Doing some calculation here and assigning to hidden fields before submission.

  theMain.action ="Begin.aspx?V=Y&NUM=<% response.write(sID)%>";
  theMain.submit;	
}
Problem is:
Once I click doRefresh, its working and carrying 'V' value as 'Y'
after that, if I place mouse on doRefresh button, in status bar, its showing
Begin.aspx?V=Y&NUM=12345

in button click event doRefresh_click, I assigned value for 'V' as 'N'. But this event firing after page_load..
I think its becasue I am calling self page.. in page_load I wrote Request("V").. Its taking value as 'Y'

How to solve this issue? How can I change the value of 'V' once user clicks Refresh button and then Submit..

Suggest me.
Reply With Quote
  #2  
Old 11-30-2006, 01:18 PM
wayneph's Avatar
wayneph wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

don't use asp:buttons. they are meant to post back to the same page. period.

One option is to set up a handler on the server side that redirects an asp:button to a new page using Response.Redirect. That's the easiest solution.

If you want to go to another page, I'd suggest using HTML buttons or hyper links.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #3  
Old 12-01-2006, 08:19 AM
netpicker9 netpicker9 is offline
Centurion
 
Join Date: Jun 2005
Posts: 127
Default Doubt

Quote:
Originally Posted by wayneph
don't use asp:buttons. they are meant to post back to the same page. period.

One option is to set up a handler on the server side that redirects an asp:button to a new page using Response.Redirect. That's the easiest solution.

If you want to go to another page, I'd suggest using HTML buttons or hyper links.
Hi,

Many Thanks.

I have one more doubt, I have a asp:button in the form, when I click that page is reloading and calling page_load event first, Is there any possibility to call button click event first once the button is clicked?

Thanks
Reply With Quote
  #4  
Old 12-01-2006, 08:27 AM
wayneph's Avatar
wayneph wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

no. Page_Load always fires first. I'd suggest spending a little time Learning the Framework, and especially the Page Life Cycle. It will make developing in ASP.NET infinitely easier.

That being said, if you have something in Page_Load that you only want to run on the inital view of the page, you can put it inside of an If Not IsPostBack Then block. The button will be detected as a postback, and that part of the Page_Load will be skipped.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->