ASP.net Buttons

netpicker9
11-30-2006, 01:02 PM
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:
'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

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.

wayneph
11-30-2006, 01:18 PM
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.

netpicker9
12-01-2006, 08:19 AM
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

wayneph
12-01-2006, 08:27 AM
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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum