Change text of link button based on selected value of dropDownList

A

Andy B

I have a dropDownList and a LinkButton. The LinkButton's text needs to
reflect the selected item in the dropDownList. So, when Subscribe is
selected in the dropDownList, the LinkButton's text needs to also be
"Subscribe". Also, if the dropDownList's selected item is Unsubscribe, the
LinkButton's text needs to be "Unsubscribe". This needs to happen without a
page postback or reload. How do I do this?
 
E

Eliyahu Goldin

You can do it client-side in javascript. You will need to view the source
for the page, locate the controls in interest in html, and figure out what
client events to handle. It may be trivial or not so depending on where on
the page the controls are.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
A

Andy B

Cant you use ajax for something like this?


Eliyahu Goldin said:
You can do it client-side in javascript. You will need to view the source
for the page, locate the controls in interest in html, and figure out what
client events to handle. It may be trivial or not so depending on where on
the page the controls are.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Andy B said:
I have a dropDownList and a LinkButton. The LinkButton's text needs to
reflect the selected item in the dropDownList. So, when Subscribe is
selected in the dropDownList, the LinkButton's text needs to also be
"Subscribe". Also, if the dropDownList's selected item is Unsubscribe, the
LinkButton's text needs to be "Unsubscribe". This needs to happen without
a page postback or reload. How do I do this?
 
E

Eliyahu Goldin

Sure, it will be much simpler. Put the controls in the same UpdatePanel and
handle server-side SelectedIndexChanged event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


Andy B said:
Cant you use ajax for something like this?


Eliyahu Goldin said:
You can do it client-side in javascript. You will need to view the source
for the page, locate the controls in interest in html, and figure out
what client events to handle. It may be trivial or not so depending on
where on the page the controls are.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Andy B said:
I have a dropDownList and a LinkButton. The LinkButton's text needs to
reflect the selected item in the dropDownList. So, when Subscribe is
selected in the dropDownList, the LinkButton's text needs to also be
"Subscribe". Also, if the dropDownList's selected item is Unsubscribe,
the LinkButton's text needs to be "Unsubscribe". This needs to happen
without a page postback or reload. How do I do this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top