Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Link Button Question (II)

Reply
Thread Tools

Link Button Question (II)

 
 
Zach
Guest
Posts: n/a
 
      05-18-2012
In ASP I can put text on a linkbutton in the aspx file.
But I don't seem to be able to change the back colour
after having clicked the link button. Is there a way to
do this?

Zach
 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-19-2012
On 5/18/2012 2:14 PM, Zach wrote:
> In ASP I can put text on a linkbutton in the aspx file.
> But I don't seem to be able to change the back colour
> after having clicked the link button. Is there a way to
> do this?


CSS

http://www.w3schools.com/css/css_link.asp

has an example.

Arne

 
Reply With Quote
 
 
 
 
Zach
Guest
Posts: n/a
 
      05-19-2012

"Arne Vajh°j" <(E-Mail Removed)> wrote in message
news:4fb6ed4d$0$291$(E-Mail Removed)...
> On 5/18/2012 2:14 PM, Zach wrote:
>> In ASP I can put text on a linkbutton in the aspx file.
>> But I don't seem to be able to change the back colour
>> after having clicked the link button. Is there a way to
>> do this?

>
> CSS
>
> http://www.w3schools.com/css/css_link.asp
>
> has an example.
>
> Arne
>

Yes that is interesting. However, using style sheets I cannot get it to
work.
I have tried different formats.

Zach.

 
Reply With Quote
 
Zach
Guest
Posts: n/a
 
      05-19-2012

"Arne Vajh°j" <(E-Mail Removed)> wrote in message
news:4fb6ed4d$0$291$(E-Mail Removed)...
> On 5/18/2012 2:14 PM, Zach wrote:
>> In ASP I can put text on a linkbutton in the aspx file.
>> But I don't seem to be able to change the back colour
>> after having clicked the link button. Is there a way to
>> do this?

>
> CSS
>
> http://www.w3schools.com/css/css_link.asp
>
> has an example.
>
> Arne
>

Arne,

I have discovered how it works.
Once you have in the style sheet e.g.

..LinkButton1
{
// some code
}

you can add

..LinkButton1:hover{
background-color: yellow;

}

Then the link button will light up yellow as you hover it
which is funky. But what you cannot do is keep the linkbutton
yellow till you klick another linkbutton so the user will know
what he/she has been referred to e.g. in a neighbouring textbox.
That would of course need something other than "hover". But
I don't see that option available.

If you create one of several click functions and in one
function you want to give the linkbutton background
colour yellow, till you click another linkbutton, then
there is no way of doing that - that I could find.

Zach.










 
Reply With Quote
 
Registered User
Guest
Posts: n/a
 
      05-19-2012
On Fri, 18 May 2012 20:14:34 +0200, "Zach" <(E-Mail Removed)> wrote:

>In ASP I can put text on a linkbutton in the aspx file.
>But I don't seem to be able to change the back colour
>after having clicked the link button. Is there a way to
>do this?
>

Change the control's BackColor property in the control's onClick event.

Assuming the markup as

<asp:LinkButton ID="LinkButton1" runat="server"
onclick="LinkButton1_Click">LinkButton</asp:LinkButton>

the color will be changed by using this event handler

protected void LinkButton1_Click(object sender, EventArgs e)
{
LinkButton1.BackColor = System.Drawing.Color.Red;
}

regards
A.G.
 
Reply With Quote
 
Zach
Guest
Posts: n/a
 
      05-19-2012

"Registered User" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Fri, 18 May 2012 20:14:34 +0200, "Zach" <(E-Mail Removed)> wrote:
>
>>In ASP I can put text on a linkbutton in the aspx file.
>>But I don't seem to be able to change the back colour
>>after having clicked the link button. Is there a way to
>>do this?
>>

> Change the control's BackColor property in the control's onClick event.
>
> Assuming the markup as
>
> <asp:LinkButton ID="LinkButton1" runat="server"
> onclick="LinkButton1_Click">LinkButton</asp:LinkButton>
>
> the color will be changed by using this event handler
>
> protected void LinkButton1_Click(object sender, EventArgs e)
> {
> LinkButton1.BackColor = System.Drawing.Color.Red;
> }
>
> regards
> A.G.


Hi,

Excellent!
Thank you.

Zach.

 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-20-2012
On 5/19/2012 9:13 AM, Zach wrote:
> "Arne Vajh°j" <(E-Mail Removed)> wrote in message
> news:4fb6ed4d$0$291$(E-Mail Removed)...
>> On 5/18/2012 2:14 PM, Zach wrote:
>>> In ASP I can put text on a linkbutton in the aspx file.
>>> But I don't seem to be able to change the back colour
>>> after having clicked the link button. Is there a way to
>>> do this?

>>
>> CSS
>>
>> http://www.w3schools.com/css/css_link.asp
>>
>> has an example.

>
> I have discovered how it works.
> Once you have in the style sheet e.g.
>
> .LinkButton1
> {
> // some code
> }
>
> you can add
>
> .LinkButton1:hover{
> background-color: yellow;
>
> }
>
> Then the link button will light up yellow as you hover it
> which is funky. But what you cannot do is keep the linkbutton
> yellow till you klick another linkbutton so the user will know
> what he/she has been referred to e.g. in a neighbouring textbox.
> That would of course need something other than "hover". But
> I don't see that option available.
>
> If you create one of several click functions and in one
> function you want to give the linkbutton background
> colour yellow, till you click another linkbutton, then
> there is no way of doing that - that I could find.


The traditional web way is that links has one style
before click and one style after first click.

CSS can do that.

CSS can not do what you describe. Which seems to be that
only latest clicked link should have a special style so
that a clicked link fall back to start style when the
next link is clicked.

Arne

 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-20-2012
On 5/19/2012 12:15 PM, Zach wrote:
> "Registered User" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> On Fri, 18 May 2012 20:14:34 +0200, "Zach" <(E-Mail Removed)> wrote:
>>> In ASP I can put text on a linkbutton in the aspx file.
>>> But I don't seem to be able to change the back colour
>>> after having clicked the link button. Is there a way to
>>> do this?
>>>

>> Change the control's BackColor property in the control's onClick event.
>>
>> Assuming the markup as
>>
>> <asp:LinkButton ID="LinkButton1" runat="server"
>> onclick="LinkButton1_Click">LinkButton</asp:LinkButton>
>>
>> the color will be changed by using this event handler
>>
>> protected void LinkButton1_Click(object sender, EventArgs e)
>> {
>> LinkButton1.BackColor = System.Drawing.Color.Red;
>> }

>
> Excellent!


It does what you want.

But I don't link the solution.

There will be styles in both CSS and code behind. That
could become rather messy.

You could use the variant where you just set the
CssClass property in the code behind and leave
the actual styles to the CSS.

Arne
 
Reply With Quote
 
Zach
Guest
Posts: n/a
 
      05-20-2012

"Arne Vajh°j" <(E-Mail Removed)> wrote in message
news:4fb84c90$0$281$(E-Mail Removed)...
> On 5/19/2012 12:15 PM, Zach wrote:
>> "Registered User" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> On Fri, 18 May 2012 20:14:34 +0200, "Zach" <(E-Mail Removed)> wrote:
>>>> In ASP I can put text on a linkbutton in the aspx file.
>>>> But I don't seem to be able to change the back colour
>>>> after having clicked the link button. Is there a way to
>>>> do this?
>>>>
>>> Change the control's BackColor property in the control's onClick event.
>>>
>>> Assuming the markup as
>>>
>>> <asp:LinkButton ID="LinkButton1" runat="server"
>>> onclick="LinkButton1_Click">LinkButton</asp:LinkButton>
>>>
>>> the color will be changed by using this event handler
>>>
>>> protected void LinkButton1_Click(object sender, EventArgs e)
>>> {
>>> LinkButton1.BackColor = System.Drawing.Color.Red;
>>> }

> >
>> Excellent!

>
> It does what you want.
>
> But I don't link the solution.
>
> There will be styles in both CSS and code behind. That
> could become rather messy.
>
> You could use the variant where you just set the
> CssClass property in the code behind and leave
> the actual styles to the CSS.
>
> Arne


Arne,

Yes it might be considered messy.
But it does work OK.
How else to do it though.

Zach.

 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-20-2012
On 5/20/2012 1:08 PM, Zach wrote:
>
> "Arne Vajh°j" <(E-Mail Removed)> wrote in message
> news:4fb84c90$0$281$(E-Mail Removed)...
>> On 5/19/2012 12:15 PM, Zach wrote:
>>> "Registered User" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> On Fri, 18 May 2012 20:14:34 +0200, "Zach" <(E-Mail Removed)> wrote:
>>>>> In ASP I can put text on a linkbutton in the aspx file.
>>>>> But I don't seem to be able to change the back colour
>>>>> after having clicked the link button. Is there a way to
>>>>> do this?
>>>>>
>>>> Change the control's BackColor property in the control's onClick event.
>>>>
>>>> Assuming the markup as
>>>>
>>>> <asp:LinkButton ID="LinkButton1" runat="server"
>>>> onclick="LinkButton1_Click">LinkButton</asp:LinkButton>
>>>>
>>>> the color will be changed by using this event handler
>>>>
>>>> protected void LinkButton1_Click(object sender, EventArgs e)
>>>> {
>>>> LinkButton1.BackColor = System.Drawing.Color.Red;
>>>> }
>> >
>>> Excellent!

>>
>> It does what you want.
>>
>> But I don't link the solution.
>>
>> There will be styles in both CSS and code behind. That
>> could become rather messy.
>>
>> You could use the variant where you just set the
>> CssClass property in the code behind and leave
>> the actual styles to the CSS.

>
> Yes it might be considered messy.
> But it does work OK.
> How else to do it though.


Set the CssClass property i the code behind and
let the CSS define what it actually does.

Arne

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Link Link Link =?Utf-8?B?REw=?= Windows 64bit 0 05-17-2005 12:15 PM
Re: Link Link Link DANGER WILL ROBINSON!!! Kevin Spencer ASP .Net 0 05-17-2005 10:41 AM
Link Button Question =?Utf-8?B?TWFubnkgQ2hvaGFu?= ASP .Net 2 04-12-2005 04:30 PM
Link Button question Darren Clark ASP .Net 1 04-10-2004 02:26 AM
Problems with Link Button and Button web controls Suzanne ASP .Net Web Controls 0 12-03-2003 02:17 PM



Advertisments