By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,830 Members | 1,758 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,830 IT Pros & Developers. It's quick & easy.

dymanic <asp:button> shenanigans

P: n/a
Hi folks,
first off, I'm using Framwork 1.1 with ASP.net and C#

I'm trying to do something quite basic and can't figure out why it won't
behave
without going into massive details I want a button on an .aspx page have
either a 'save' caption and 'save' commandname or a 'close' caption and a
'close' commandname
The caption necessity is obvious, but the commandname is important to
because the event stub that is tied to that button (just by double-clicking
the 'neutral' button in the designer window) then checks the command name and
decides what to do

in the non postback portion of the page_load, I have code that sets up the
button properties the first time (i.e not on postback).

now inside the event stub you could say
Switch case commandname etc...
if it's close do close stuff and if it's save do save stuff

however I can't figure out a way to do this dynamically from a database
table coming into a dataTable and somehow keep this information saved in the
button during every subsequent postback for that user.

hence my question in a nutshell is:
Essentially I have a button that is getting its commandname and text
properties from a database, but it forgets what they are on every postback,
is there a way of dynamically setting these asp:button properties and having
the button remember them for the lifetime of the use of the page (for that
user), I know about using a session object, but is there some more automatic
way (i.e a feature) to make it remember it's properties as viewstate doesn't
seem to do it.

Regards and thanks in advance,
CharlesA

Mar 24 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Have you tried using the button's CommandArgument property?


"CharlesA" <Ch******@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
Hi folks,
first off, I'm using Framwork 1.1 with ASP.net and C#

I'm trying to do something quite basic and can't figure out why it won't
behave
without going into massive details I want a button on an .aspx page have
either a 'save' caption and 'save' commandname or a 'close' caption and a
'close' commandname
The caption necessity is obvious, but the commandname is important to
because the event stub that is tied to that button (just by
double-clicking
the 'neutral' button in the designer window) then checks the command name
and
decides what to do

in the non postback portion of the page_load, I have code that sets up the
button properties the first time (i.e not on postback).

now inside the event stub you could say
Switch case commandname etc...
if it's close do close stuff and if it's save do save stuff

however I can't figure out a way to do this dynamically from a database
table coming into a dataTable and somehow keep this information saved in
the
button during every subsequent postback for that user.

hence my question in a nutshell is:
Essentially I have a button that is getting its commandname and text
properties from a database, but it forgets what they are on every
postback,
is there a way of dynamically setting these asp:button properties and
having
the button remember them for the lifetime of the use of the page (for that
user), I know about using a session object, but is there some more
automatic
way (i.e a feature) to make it remember it's properties as viewstate
doesn't
seem to do it.

Regards and thanks in advance,
CharlesA

Mar 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.