How to change font size and color of selected linkbutton.

I built a very simple slideshow app in asp.net. I have a list of linkbuttons in a repeater control. When you click one of the links it loads a specific photo in the slideshow.

How can I accent or highlight (change the font size and color) the selected linkbutton (link or photonumber).

Thank you for any response, it is appreciated!

John Brock

This is my current code below:

<%@ Page Language="vb" Debug="true" %>
<script language="vb" runat="server">
Dim iPhotoNumber  As Integer
Dim iMaxPhotoNumber As Integer
Dim sTheSlide     As String
Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
 iMaxPhotoNumber = 173
 lblMaxPhotoNumber.Text = iMaxPhotoNumber
 
 If Not IsPostBack Then
  If iPhotoNumber < 1 Then
   iPhotoNumber = 1
  End If
  
  lblPhotoNumber.Text = iPhotoNumber
  
  'get the next photo
  if iPhotoNumber < 10 then
   sTheSlide = "photos/photo0" & iPhotoNumber & ".jpg"
  else
   sTheSlide = "photos/photo" & iPhotoNumber & ".jpg"
  end if
  
  imgTheSlide.ImageURL = sTheSlide
  
  Dim a1 As New ArrayList
  Dim i As Integer
  
  For i = 1 To iMaxPhotoNumber
   a1.Add(CStr(i))
  Next
  
  Repeater1.DataSource = a1
  Repeater1.DataBind()
 Else
  iPhotoNumber = CInt(lblPhotoNumber.Text)
 End If
End Sub
Sub NextBtn_Click(Sender As Object, E As EventArgs)
 if iPhotoNumber = iMaxPhotoNumber then
  iPhotoNumber = 1
 else
  iPhotoNumber = iPhotoNumber + 1
 end if
 
 lblPhotoNumber.Text = iPhotoNumber
 
 'get the next photo
 if iPhotoNumber < 10 then
  sTheSlide = "photos/photo0" & iPhotoNumber & ".jpg"
 else
  sTheSlide = "photos/photo" & iPhotoNumber & ".jpg"
 end if
 
 imgTheSlide.ImageURL = sTheSlide
End Sub
Sub BackBtn_Click(Sender As Object, E As EventArgs)
    if iPhotoNumber - 1 < 1 then
  iPhotoNumber = iMaxPhotoNumber
 else
  iPhotoNumber = iPhotoNumber - 1
 end if
 
 lblPhotoNumber.Text = iPhotoNumber
 
 'get the next photo
 if iPhotoNumber < 10 then
  sTheSlide = "photos/photo0" & iPhotoNumber & ".jpg"
 else
  sTheSlide = "photos/photo" & iPhotoNumber & ".jpg"
 end if
 
 imgTheSlide.ImageURL = sTheSlide
End Sub
Sub PhotoLink_Click(sender As Object, e As CommandEventArgs)
 iPhotoNumber = e.CommandArgument
 
 lblPhotoNumber.Text = iPhotoNumber
 
 'get the next photo
 if iPhotoNumber < 10 then
  sTheSlide = "photos/photo0" & iPhotoNumber & ".jpg"
 else
  sTheSlide = "photos/photo" & iPhotoNumber & ".jpg"
 end if
 
 imgTheSlide.ImageURL = sTheSlide
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>12700 Travers Trail Photo Slideshow</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
</head>
<body MS_POSITIONING="GridLayout" vlink="#0000ff" style="PADDING-BOTTOM:0px;PADDING-TOP:0px">
<form id="frmSlideShow" runat="server">
 <table cellpadding="2" cellspacing="0" align="center">
  <tr>
   <td bgcolor="navy" align="left">
   <asp:Label id="lblSlideshowTitle" runat="server" Font-Bold="True" ForeColor="#ffffff" Text="12700 Travers Trail Photo Slideshow" />
   </td>
   <td bgcolor="navy" align="right">
    <asp:Label id="lblPhotoNumber" runat="server" Font-Bold="True" ForeColor="#ffffff" />
    <asp:Label runat="server" Font-Bold="True" ForeColor="#ffffff" Text=" of " />
    <asp:Label id="lblMaxPhotoNumber" runat="server" Font-Bold="True" ForeColor="#ffffff" />
   </td>
  </tr>
  <tr>
   <td align="center" valign="middle" colspan="2"><hr width="97%" align="center">
    <asp:Image id="imgTheSlide" ImageAlign="middle" BorderColor="navy" BorderWidth="12" runat="server" />
    <hr width="97%" align="center">
   </td>
  </tr>
  <tr>
   <td align="center" valign="middle" colspan="2" class="vbStyleText">
    <asp:Button id="btnBack" text="< Back" OnClick="BackBtn_Click" runat="server" />
    <asp:Button id="btnNext" text="Next >" OnClick="NextBtn_Click" runat="server" />
   </td>
  </tr>
 </table>
 <table border="0" width="535" cellpadding="2" cellspacing="0" align="center">
  <tr>
   <td align="center">
             <div align="left">
    <asp:Repeater id="Repeater1" runat="server">
     <ItemTemplate>
                         <asp:LinkButton
       CommandArgument="<%# Container.DataItem %>"
       CommandName="cmdPhotoLink<%# Container.DataItem %>"
       Font-Names="Arial, Helvetica, sans-serif"
       Font-Size="10px"
                           ForeColor="#0000FF"
       runat="server"
       Text="<%# Container.DataItem %>"
       OnCommand="PhotoLink_Click">
      </asp:LinkButton>
     </ItemTemplate>
    </asp:Repeater>
                </div>
   </td>
  </tr>
 </table>
</form>
</body>
</html>

Thank you!

John W. Brock
-1
daddyb1
10/6/2005 4:16:31 PM
asp.net.web-forms 93655 articles. 3 followers. Follow

3 Replies
577 Views

Similar Articles

[PageSpeed] 35

Hi,

when you say that you like to change the font and color of your linkbuttons when should this happen? When the enduser hovers over a button or when the button has been clicked and a new image is shown?

The former case can be solved using CSS where you set the specific settings you wish (color and font size).

for example:

a { font:10px; color:#f00; }
a:hover { font:12px; color:#ff0; }

The latter solution can be done through server side ASP.NET code when you handle the event of the button.

Grz, Kris.
Read my blog. Handy Firefox plugins for web developers.


Workaround for non working Mark as answer buttons.
1
XIII
10/6/2005 7:17:37 PM
I would like it to occur on the click of the LinkButton. I do not know what to do in the Command Event.

Sub LinkCommand_Click (Sender As Object, E As CommandEventArgs)
       'not sure what to do here to change font size and color on click
End Sub

Thanks so much!

John Brock
Thank you!

John W. Brock
1
daddyb1
10/6/2005 8:15:17 PM
Hi,

In Page_Load, you can use

LinkButton.Attributes.Add("onClick","SetAttributes(this)");

Now, in JavaScript you can write a function like

function SetAttributes(objLinkButton)
{
  //
}

where you can set the properties for the LinkButton.
------------------------------

Deepak Vasudevan

http://lavanyadeepak.blogspot.com/

1 972 756 0458 (Ext 1046)

91 98400 26014

-------
1
deepak
10/7/2005 2:01:25 PM
Reply:

Similar Artilces:

How to change tree view's (web control) back color, font color and font size using CSS (Cascading Style Shteets)
Hi All, I have created tree view (web control) but i want to change all the properties of it, through single style sheet. Like all other controls (label, text box and combo box) it's not possible to change all the properties of treeview through single style sheet by including it to the contol ???? Please help........ MAITRAY. Sorry. No external css. but these attributes: DefaultStyle="background:#CCCCCC;border:solid 1px;color:black;font-size:8pt" HoverStyle="color:blue;font-name:Arial" SelectedStyle="c...

changing default font size does not affect font size on form buttons and input fields.
Hello, in https://bugzilla.mozilla.org/show_bug.cgi?id=305109 I propose that changing the default font size in Preferences should also change the font sizes for form controls. On windows it works this way. Concerning Unix, though, the form controls keep their size, even if you adjust the default font size in Firefox preferences. This makes for ugly form controls if you do not adjust your GTK settings along with your Firefox default font size. But there is a workaround: you can also make Firefox scale the form controls by applying the following changes to 'font:' li...

How to change the style (color,font) of selected Linkbutton in Datalist
I have a datalist with a linkbutton for each category in my database. I'd like to change the color of whatever button is selected, and leave the other buttons the regular background color, so that users know which category they are viewing. I can change the backcolor using objButton.BackColor = System.Drawing.Color.Bisque but I don't know how to change it back to the original color once I select a different item. Thanks! If one of your other buttons is still the original color, just change it back to that color objButton.BackColor = objButton2.Backcolor  Bryan SampicaAuction ...

How to change URL style (font/size/color) in navigation to indicate that the current page has been selected?
What if I wanted to change the URL style (font/size/color) in the navigation to indicate that the current page has been selected? For example, Let's say that the Navigation has 4 items [Home | About Us | Help | Customer Service]. User clicks on Help. How would I be able to change the style of the Help link to indicate that it's been selected?Ideally - I would like to remove the URL's href + change font color, etc - for the current/selected page. In Classic ASP, I was able to check the page's url and via an IF statement change the style of the link for the select...

Color Palette for user to select color at runtime on a web form
Hello friends Is is possible to pop up a color palette,on a button click for the user to select a color from the palette on a WEB FORM. It is possible on a windows forms, but currently i am looking for a WEB FORM based color palette. Let me know , if any one know the exact API. Sincerely Nihar There is no such buit in thing in asp.net, you will have to create your own browserbased colorpicker. Search in google will give you lot of third partycolor picker in asp.net some of them are free and some of then charge money but you can take idea and build your own.Jig...

Changing the default font size is VS.net for VB.net
Subject kinda says it all. Surely there must be a way to changing the default font size for the items in the forms. Thanks for the help in advance. Daniel Yes in Tools Options, I believe its Text Editor > Basic. BrianBrian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4)....

Signature font and color changes to message font and color
My first post. When I compose a message no matter what the signature font and color is set to, it changes to whatever the font and color is of the message. Is there a fix for this? I would ask my job's tech support but I wouldn't trust them to sit the right way on a toilet seat. -- doover ------------------------------------------------------------------------ doover, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, ...

In .NET, font color changes in a string
In modern .NET do we still alter the changes to the font inline or with a class?Like:         if (strGoal.Equals(""))        {            QueryResult.Text = "You Must Enter a <font color='red'>Goal Name</font> before proceeding";            return;        } Or:        if (strGoal.Equals(""))&...

How Change Font Size and Color in a TGrid ?!
hi everyone, i'm a new user of firemonkey and i try to change the font color or size in a TGrid ! it's pretty easy in VCL but i don't find a way to do it in Firemonkey framework ! i already take a look to the component property and also to a way to do it by using a StyleBook (TextCellStyle) but without success ! can you help ?! thanks Have you figured this out? I have the same requirement. I would like to change column colors and font sizes in my TGrid. > {quote:title=javaid adnan wrote:}{quote} > i'm a new user of firemonkey and i try to change the font ...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

superreview requested: [Bug 120401] Font selection in pref. does not work (Hebrew, Arabic, CE, Baltic, Cyrillic, CJK, etc) : [Attachment 155201] Add change to default font size (as in bug 143557)
Asaf Romano <bugs.mano@mail-central.com> has asked Simon Fraser <sfraser@aol.net> for superreview: Bug 120401: Font selection in pref. does not work (Hebrew, Arabic, CE, Baltic, Cyrillic, CJK, etc) http://bugzilla.mozilla.org/show_bug.cgi?id=120401 Attachment 155201: Add change to default font size (as in bug 143557) http://bugzilla.mozilla.org/attachment.cgi?id=155201&action=edit ------- Additional Comments from Asaf Romano <bugs.mano@mail-central.com> Requsting r/sr for this. I will add some comments here later. ...

superreview granted: [Bug 120401] Font selection in pref. does not work (Hebrew, Arabic, CE, Baltic, Cyrillic, CJK, etc) : [Attachment 155201] Add change to default font size (as in bug 143557)
Simon Fraser <sfraser@aol.net> has granted Asaf Romano <bugs.mano@mail-central.com>'s request for superreview: Bug 120401: Font selection in pref. does not work (Hebrew, Arabic, CE, Baltic, Cyrillic, CJK, etc) http://bugzilla.mozilla.org/show_bug.cgi?id=120401 Attachment 155201: Add change to default font size (as in bug 143557) http://bugzilla.mozilla.org/attachment.cgi?id=155201&action=edit ...

Color changes AND font changes...
I would REALLY like to change the fonts for calendars just like I do with BG colors. Can I do it by adding something like font-size: 15pt !important in the calendar ICS file? Thanx, zeddock PS. I notice many patches are referenced here. Why is there not a more regular Sunbird release, nightly or weekly? zeddock wrote: > I would REALLY like to change the fonts for calendars just like I do > with BG colors. Can I do it by adding something like > font-size: 15pt !important > in the calendar ICS file? > > Thanx, > zeddock > > PS. I notice ...

How to change the font color of SELECTED PAGE INDEX
Hi, I am working on datagrid in which i am displaying some records from database. I am implementing Paging and the pagerstyle mode is NUMERICPAGES. When i click on a page no., the contents will be displayed and the "selected page index" will not have a link but other pages will have. I want to have a different color for the "selected index" page number among other page no.s. How can we do it. Can anyone help me... Thanx in advance. Kishan D. Just specify the CSS class of the pager style: <PagerStyle CssClass="MyColouredStyle" .... ...

Web resources about - How to change font size and color of selected linkbutton. - asp.net.web-forms

Technology - BioLite Stove
Shop News FAQs CampStove HomeStove About Our Mission & Story Technology Contact Us Jobs BioLite Technology: Converting Waste Heat into Electricity ...

Flex Examples
Just a bunch of Adobe Books About Me About You Tags Links Flex 3 (Codename: Moxie) Flex 4 (Codename: Gumbo) Flex Hero Colophon Setting the icon ...

Health & Safety Watch - Food, Consumer Product, and Drug Real-time Recalls; Disease Outbreaks and Public ...
An innovative information service led by public health experts that provides critical real-time public health information tailored to the needs ...

Microfinance and microcredit
Information about microfinance and microcredit. Get the latest from the world of microfinance!

ButtonExtensions Module
AddConfirmation() This Extension Method extends the Button, ImageButton, and LinkButton by adding a JavaScript confirmation dialog that appears ...

Sell Your Item
Join your friends and neighbors in a gigantic online yard sale on Facebook.

Register for projects, internship, free lance job & outsourcing work.
For doing projects, internship, small job online - Enroll urself. Companies can get multiple project ideas from talented students at minimum ...


DropDown Sample
Samples HOME Accordion AjaxFileUpload AlwaysVisibleControl Animation AreaChart AsyncFileUpload AutoComplete BalloonPopup BarChart BubbleChart ...

Atlas causing javascript conflicts? : The Official Forums for Microsoft ASP.NET
I am using an UpdatePanel that contains several LinkButtons and a GridView control. The LinkButtons are used to select/deselect all of the checkboxes ...

Resources last updated: 11/24/2015 2:43:58 PM