Home All Groups Group Topic Archive Search About

Determine Which Button Pressed

Author
22 Aug 2006 4:54 PM
Mike Collins
In my page initialize, I am loading dynamic controls for a survey. On the
survey, I have a stop button. If the user clicks the stop button, because of
the page life cycle, the initialize and page load events run before the
button click and reloads a bunch of controls. Is there a way to keep these
events from running with a button control. The click event of the button has
code to save the user's place in the survey and I only want it to run. Thanks.

Author
22 Aug 2006 5:19 PM
Bruno Alexandre
did u tried use the Wizard component under asp.net 2.0 to do such task???

--

Bruno Alexandre
"a Portuguese in København, Danmark"



Show quote
"Mike Collins" <MikeColl***@discussions.microsoft.com> escreveu na mensagem
news:BB51CC4E-06A8-4206-BA38-CC732E0E4753@microsoft.com...
> In my page initialize, I am loading dynamic controls for a survey. On the
> survey, I have a stop button. If the user clicks the stop button, because
> of
> the page life cycle, the initialize and page load events run before the
> button click and reloads a bunch of controls. Is there a way to keep these
> events from running with a button control. The click event of the button
> has
> code to save the user's place in the survey and I only want it to run.
> Thanks.
Author
22 Aug 2006 5:33 PM
Mike Collins
I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.

Show quote
"Bruno Alexandre" wrote:

> did u tried use the Wizard component under asp.net 2.0 to do such task???
>
> --
>
> Bruno Alexandre
> "a Portuguese in København, Danmark"
>
>
>
> "Mike Collins" <MikeColl***@discussions.microsoft.com> escreveu na mensagem
> news:BB51CC4E-06A8-4206-BA38-CC732E0E4753@microsoft.com...
> > In my page initialize, I am loading dynamic controls for a survey. On the
> > survey, I have a stop button. If the user clicks the stop button, because
> > of
> > the page life cycle, the initialize and page load events run before the
> > button click and reloads a bunch of controls. Is there a way to keep these
> > events from running with a button control. The click event of the button
> > has
> > code to save the user's place in the survey and I only want it to run.
> > Thanks.
>
>
>
Author
22 Aug 2006 5:44 PM
Juan T. Llibre
re:
>I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.

What the h*ll are you doing using ASP.NET 1.0 ?

At the very least you should be using ASP.NET 1.1.
although everybody should be, at least, testing ASP.NET 2.0.



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
Show quote
"Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
news:CD7626C6-1789-41F5-A0C9-7663FE356BE9@microsoft.com...
>I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
>
> "Bruno Alexandre" wrote:
>
>> did u tried use the Wizard component under asp.net 2.0 to do such task???
>>
>> --
>>
>> Bruno Alexandre
>> "a Portuguese in København, Danmark"
>>
>>
>>
>> "Mike Collins" <MikeColl***@discussions.microsoft.com> escreveu na mensagem
>> news:BB51CC4E-06A8-4206-BA38-CC732E0E4753@microsoft.com...
>> > In my page initialize, I am loading dynamic controls for a survey. On the
>> > survey, I have a stop button. If the user clicks the stop button, because
>> > of
>> > the page life cycle, the initialize and page load events run before the
>> > button click and reloads a bunch of controls. Is there a way to keep these
>> > events from running with a button control. The click event of the button
>> > has
>> > code to save the user's place in the survey and I only want it to run.
>> > Thanks.
>>
>>
>>
Author
22 Aug 2006 6:13 PM
Mike Collins
That was a typo. Is this better: v1.1.4322. I would like help instead of
criticism.

Show quote
"Juan T. Llibre" wrote:

> re:
> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
>
> What the h*ll are you doing using ASP.NET 1.0 ?
>
> At the very least you should be using ASP.NET 1.1.
> although everybody should be, at least, testing ASP.NET 2.0.
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
> news:CD7626C6-1789-41F5-A0C9-7663FE356BE9@microsoft.com...
> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
> >
> > "Bruno Alexandre" wrote:
> >
> >> did u tried use the Wizard component under asp.net 2.0 to do such task???
> >>
> >> --
> >>
> >> Bruno Alexandre
> >> "a Portuguese in København, Danmark"
> >>
> >>
> >>
> >> "Mike Collins" <MikeColl***@discussions.microsoft.com> escreveu na mensagem
> >> news:BB51CC4E-06A8-4206-BA38-CC732E0E4753@microsoft.com...
> >> > In my page initialize, I am loading dynamic controls for a survey. On the
> >> > survey, I have a stop button. If the user clicks the stop button, because
> >> > of
> >> > the page life cycle, the initialize and page load events run before the
> >> > button click and reloads a bunch of controls. Is there a way to keep these
> >> > events from running with a button control. The click event of the button
> >> > has
> >> > code to save the user's place in the survey and I only want it to run.
> >> > Thanks.
> >>
> >>
> >>
>
>
>
Author
22 Aug 2006 6:26 PM
Juan T. Llibre
re:
> That was a typo. Is this better: v1.1.4322.

Yes, that's better.

re:
>I would like help instead of criticism.

Posting correct information would help you in getting help.

You should consider upgrading to 2.0.
Is there anything stopping you from doing that ?




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
Show quote
"Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
news:912717D9-6809-48E1-B3BF-ABA4A9EFF9C0@microsoft.com...
> That was a typo. Is this better: v1.1.4322. I would like help instead of
> criticism.

> "Juan T. Llibre" wrote:
>
>> re:
>> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
>>
>> What the h*ll are you doing using ASP.NET 1.0 ?
>>
>> At the very least you should be using ASP.NET 1.1.
>> although everybody should be, at least, testing ASP.NET 2.0.
>>
>> Juan T. Llibre, asp.net MVP

>> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
>> news:CD7626C6-1789-41F5-A0C9-7663FE356BE9@microsoft.com...
>> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.

>> >> did u tried use the Wizard component under asp.net 2.0 to do such task???
>> >>
>> >> Bruno Alexandre
Author
22 Aug 2006 6:39 PM
Mike Collins
Thanks...I realize correct information is much better when needing help.
Sorry for the typo.

The office where I work just started using VS 2003 this year, so there are
no plans to upgrade for at least 2 years.

Show quote
"Juan T. Llibre" wrote:

> re:
> > That was a typo. Is this better: v1.1.4322.
>
> Yes, that's better.
>
> re:
> >I would like help instead of criticism.
>
> Posting correct information would help you in getting help.
>
> You should consider upgrading to 2.0.
> Is there anything stopping you from doing that ?
>
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
> news:912717D9-6809-48E1-B3BF-ABA4A9EFF9C0@microsoft.com...
> > That was a typo. Is this better: v1.1.4322. I would like help instead of
> > criticism.
>
> > "Juan T. Llibre" wrote:
> >
> >> re:
> >> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
> >>
> >> What the h*ll are you doing using ASP.NET 1.0 ?
> >>
> >> At the very least you should be using ASP.NET 1.1.
> >> although everybody should be, at least, testing ASP.NET 2.0.
> >>
> >> Juan T. Llibre, asp.net MVP
>
> >> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
> >> news:CD7626C6-1789-41F5-A0C9-7663FE356BE9@microsoft.com...
> >> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
>
> >> >> did u tried use the Wizard component under asp.net 2.0 to do such task???
> >> >>
> >> >> Bruno Alexandre
>
>
>
Author
22 Aug 2006 6:54 PM
Juan T. Llibre
re:
> Thanks...I realize correct information is much better when needing help.
> Sorry for the typo.

No problem...

re:
> The office where I work just started using VS 2003 this year,
> so there are no plans to upgrade for at least 2 years.

Do the guys who run your office realize that VWD is free ?
Also, do they realize that running the .Net Framework 2.0 is free ?

They're free downloads.

Get VWD at :
http://msdn.microsoft.com/vstudio/express/vwd/download/

You can also download the free .Net Framework 2.0 redistributable at :
http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-436...

And, you can download, for free, the .Net Framework 2.0 SDK at :
http://www.microsoft.com/downloads/details.aspx?familyid=FE6F2099-B7B...

With VWD and the .Net Framework redistributable -or the SDK- there's no need
to spend money for an IDE which *can* target .Net Framework 2.0 objects.

You can continue to use VS 2003 for your .Net Framework/ASP.NET 1.1 development.
That won't interfere with your *free* development of ASP.NET 2.0 apps.



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================

Show quote
"Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
news:4892409B-D0D7-41B2-995D-FCFABDBEDEEA@microsoft.com...
> Thanks...I realize correct information is much better when needing help.
> Sorry for the typo.
>
> The office where I work just started using VS 2003 this year, so there are
> no plans to upgrade for at least 2 years.
>
> "Juan T. Llibre" wrote:
>
>> re:
>> > That was a typo. Is this better: v1.1.4322.
>>
>> Yes, that's better.
>>
>> re:
>> >I would like help instead of criticism.
>>
>> Posting correct information would help you in getting help.
>>
>> You should consider upgrading to 2.0.
>> Is there anything stopping you from doing that ?
>>
>>
>>
>>
>> Juan T. Llibre, asp.net MVP
>> aspnetfaq.com : http://www.aspnetfaq.com/
>> asp.net faq : http://asp.net.do/faq/
>> foros de asp.net, en español : http://asp.net.do/foros/
>> ===================================
>> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
>> news:912717D9-6809-48E1-B3BF-ABA4A9EFF9C0@microsoft.com...
>> > That was a typo. Is this better: v1.1.4322. I would like help instead of
>> > criticism.
>>
>> > "Juan T. Llibre" wrote:
>> >
>> >> re:
>> >> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
>> >>
>> >> What the h*ll are you doing using ASP.NET 1.0 ?
>> >>
>> >> At the very least you should be using ASP.NET 1.1.
>> >> although everybody should be, at least, testing ASP.NET 2.0.
>> >>
>> >> Juan T. Llibre, asp.net MVP
>>
>> >> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
>> >> news:CD7626C6-1789-41F5-A0C9-7663FE356BE9@microsoft.com...
>> >> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
>>
>> >> >> did u tried use the Wizard component under asp.net 2.0 to do such task???
>> >> >>
>> >> >> Bruno Alexandre
>>
>>
>>
Author
22 Aug 2006 7:17 PM
Mike Collins
I did not realize that VS 2003 could take advantage of the new things in the
2.0 framework, but we have a very rigid process that keeps us from being to
upgrade until approved by higher until they have "fully" tested it. The one
great day I am on my own, I'll work with all the latest and greatest :)

Do you know if I can do what I need in VS 2003?

Show quote
"Juan T. Llibre" wrote:

> re:
> > Thanks...I realize correct information is much better when needing help.
> > Sorry for the typo.
>
> No problem...
>
> re:
> > The office where I work just started using VS 2003 this year,
> > so there are no plans to upgrade for at least 2 years.
>
> Do the guys who run your office realize that VWD is free ?
> Also, do they realize that running the .Net Framework 2.0 is free ?
>
> They're free downloads.
>
> Get VWD at :
> http://msdn.microsoft.com/vstudio/express/vwd/download/
>
> You can also download the free .Net Framework 2.0 redistributable at :
> http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-436...
>
> And, you can download, for free, the .Net Framework 2.0 SDK at :
> http://www.microsoft.com/downloads/details.aspx?familyid=FE6F2099-B7B...
>
> With VWD and the .Net Framework redistributable -or the SDK- there's no need
> to spend money for an IDE which *can* target .Net Framework 2.0 objects.
>
> You can continue to use VS 2003 for your .Net Framework/ASP.NET 1.1 development.
> That won't interfere with your *free* development of ASP.NET 2.0 apps.
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
>
> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
> news:4892409B-D0D7-41B2-995D-FCFABDBEDEEA@microsoft.com...
> > Thanks...I realize correct information is much better when needing help.
> > Sorry for the typo.
> >
> > The office where I work just started using VS 2003 this year, so there are
> > no plans to upgrade for at least 2 years.
> >
> > "Juan T. Llibre" wrote:
> >
> >> re:
> >> > That was a typo. Is this better: v1.1.4322.
> >>
> >> Yes, that's better.
> >>
> >> re:
> >> >I would like help instead of criticism.
> >>
> >> Posting correct information would help you in getting help.
> >>
> >> You should consider upgrading to 2.0.
> >> Is there anything stopping you from doing that ?
> >>
> >>
> >>
> >>
> >> Juan T. Llibre, asp.net MVP
> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> asp.net faq : http://asp.net.do/faq/
> >> foros de asp.net, en español : http://asp.net.do/foros/
> >> ===================================
> >> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
> >> news:912717D9-6809-48E1-B3BF-ABA4A9EFF9C0@microsoft.com...
> >> > That was a typo. Is this better: v1.1.4322. I would like help instead of
> >> > criticism.
> >>
> >> > "Juan T. Llibre" wrote:
> >> >
> >> >> re:
> >> >> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
> >> >>
> >> >> What the h*ll are you doing using ASP.NET 1.0 ?
> >> >>
> >> >> At the very least you should be using ASP.NET 1.1.
> >> >> although everybody should be, at least, testing ASP.NET 2.0.
> >> >>
> >> >> Juan T. Llibre, asp.net MVP
> >>
> >> >> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
> >> >> news:CD7626C6-1789-41F5-A0C9-7663FE356BE9@microsoft.com...
> >> >> >I am only using ASP.Net 1.0. As far as I know, there is no wizard for that.
> >>
> >> >> >> did u tried use the Wizard component under asp.net 2.0 to do such task???
> >> >> >>
> >> >> >> Bruno Alexandre
> >>
> >>
> >>
>
>
>
>
Author
22 Aug 2006 7:28 PM
Mark Rae
"Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
news:B7970152-C425-4120-9616-3A5F663C3DFE@microsoft.com...

>I did not realize that VS 2003 could take advantage of the new things in
>the
> 2.0 framework,

It can't, but that's not what Juan actually said...

> but we have a very rigid process that keeps us from being to
> upgrade until approved by higher until they have "fully" tested it. The
> one
> great day I am on my own, I'll work with all the latest and greatest :)

Maybe that time has come...

> Do you know if I can do what I need in VS 2003?

private void Page_Init(object sender, EventArgs e)
{
    // create your dynamic buttons - you'll need to do this every time the
page loads irrespective of whether it's been posted back or not

    if (!Page.IsPostback)
    {
        // do something which won't happen when the page is posted back
    }
}

private void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostback)
    {
        // do something which won't happen when the page is posted back
    }
}
Author
22 Aug 2006 7:23 PM
Mark Rae
"Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
news:BB51CC4E-06A8-4206-BA38-CC732E0E4753@microsoft.com...

> In my page initialize, I am loading dynamic controls for a survey. On the
> survey, I have a stop button. If the user clicks the stop button, because
> of
> the page life cycle, the initialize and page load events run before the
> button click and reloads a bunch of controls. Is there a way to keep these
> events from running with a button control. The click event of the button
> has
> code to save the user's place in the survey and I only want it to run.
> Thanks.

You've obviously tried if (!Page.IsPostback) ...?
Author
22 Aug 2006 7:48 PM
Mike Collins
This is what I have right now in the initialize event:

private void Page_Init(object sender, EventArgs e)
{
  InitializeComponent();

  if (Page.IsPostBack)
  {
    //Load dynamic controls.
    LoadNextSurveyPage();
  }

  base.OnInit(e);
}

I am doing Page.IsPostBack so it does not run on the initial load because we
are displaying instructions first., so I am wondering how to use the "stop
survey" button that I added through the designer to keep the above from
running.

Show quote
"Mark Rae" wrote:

> "Mike Collins" <MikeColl***@discussions.microsoft.com> wrote in message
> news:BB51CC4E-06A8-4206-BA38-CC732E0E4753@microsoft.com...
>
> > In my page initialize, I am loading dynamic controls for a survey. On the
> > survey, I have a stop button. If the user clicks the stop button, because
> > of
> > the page life cycle, the initialize and page load events run before the
> > button click and reloads a bunch of controls. Is there a way to keep these
> > events from running with a button control. The click event of the button
> > has
> > code to save the user's place in the survey and I only want it to run.
> > Thanks.
>
> You've obviously tried if (!Page.IsPostback) ...?
>
>
>
Author
22 Aug 2006 9:00 PM
Kevin Jones
You can't stop the events from firing but you might be able to use some
heuristics to determine which button caused the postback.

In your Page_xxx handlers you can look at the post body and check to see
if the btn data is in there. For example, if I have this

<asp:Button runat="server" id="stop" Text="Stop Survey"/>

Then in the event handler the Request object's items collection will
have a key called "stop" with the value "Stop Survey" so you could look
for that combination in the handlers alongside the IsPostback flag and
use that information to not use the postback.

If this is too kludgy then you could use a hidden form field, then when
the user clicks on the stop button use a javascript function to set the
value of the control before sending the postback to the server. You
could then use the items collection to look for that value,

Kevin
Author
22 Aug 2006 9:23 PM
Mike Collins
Thanks...I'll look into doing that.

Show quote
"Kevin Jones" wrote:

> You can't stop the events from firing but you might be able to use some
> heuristics to determine which button caused the postback.
>
> In your Page_xxx handlers you can look at the post body and check to see
> if the btn data is in there. For example, if I have this
>
> <asp:Button runat="server" id="stop" Text="Stop Survey"/>
>
> Then in the event handler the Request object's items collection will
> have a key called "stop" with the value "Stop Survey" so you could look
> for that combination in the handlers alongside the IsPostback flag and
> use that information to not use the postback.
>
> If this is too kludgy then you could use a hidden form field, then when
> the user clicks on the stop button use a javascript function to set the
> value of the control before sending the postback to the server. You
> could then use the items collection to look for that value,
>
> Kevin
>
Author
23 Aug 2006 1:36 PM
Mike Collins
I added this to the initialize event and it worked...thanks.

if ((Page.IsPostBack) && (Request.Params.Get("btnStop") == null))
{
   ...code to load dynamic controls
}


Show quote
"Kevin Jones" wrote:

> You can't stop the events from firing but you might be able to use some
> heuristics to determine which button caused the postback.
>
> In your Page_xxx handlers you can look at the post body and check to see
> if the btn data is in there. For example, if I have this
>
> <asp:Button runat="server" id="stop" Text="Stop Survey"/>
>
> Then in the event handler the Request object's items collection will
> have a key called "stop" with the value "Stop Survey" so you could look
> for that combination in the handlers alongside the IsPostback flag and
> use that information to not use the postback.
>
> If this is too kludgy then you could use a hidden form field, then when
> the user clicks on the stop button use a javascript function to set the
> value of the control before sending the postback to the server. You
> could then use the items collection to look for that value,
>
> Kevin
>

AddThis Social Bookmark Button