473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Change Hyperlink style dynamically

Hello All,

I want to change the size of my hyper lnks in a repeater control dynamially
using the onItemBound event, as under, but cannot seem to understand how to
alter the properties to do that.

<asp:HiddenField ID="maxFrequency" runat="server" />

<ASP:Repeater id="repTags" runat="server" OnItemDataBound="ShowFrequery" >

<ItemTemplate>

<a id="lnkFeedTags" href='<%# "../resources/showentries.aspx?strTag=" +
Server.UrlEncode((((DataRowView)Container.DataItem )["sTag"]).ToString())%>'
runat="server" ><%# DataBinder.Eval(Container.DataItem,
"sTag").ToString()%></a>

<asp:HiddenField ID="lnkFeedFrequency" runat="server" Value='<%#
DataBinder.Eval(Container.DataItem, "nTagsCount").ToString()%>'/>

</ItemTemplate>

</ASP:Repeater>

Code behind is

public void ShowFrequery(Object sender, RepeaterItemEventArgs e)

{

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)

{

string strValue =
((HiddenField)e.Item.FindControl("lnkFeedFrequency ")).Value;

string strMax = maxFrequency.Value;

if ((strValue != "") && (strMax != ""))

{

string strSize = string.Empty;

int frqSize = (int.Parse(strValue) / int.Parse(maxFrequency.Value)) * 7;

switch (frqSize)

{

case 1: strSize = "x-small";

break;

case 2: strSize = "small";

break;

case 3: strSize = "smaller";

break;

case 4: strSize = "medium";

break;

case 5: strSize = "larger";

break;

case 6: strSize = "large";

break;

case 7: strSize = "x-large";

break;

default: strSize = "x-small";

break;

}

Style s = new Style();
((HyperLink)e.Item.FindControl("lnkFeedTags")).Mer geStyle(string) =
"font-size:" + strSize;

}
}

}

Thanks a lot,

Imran.
Nov 19 '05 #1
2 2009
I would look to change the name of the CSS class the link uses, then setup
CSS classes with these different styles, rather than use MergeStyle.
--
Clint Hill MCAD
H3O Software
http://www.h3osoftware.com
"Imran Aziz" wrote:
Hello All,

I want to change the size of my hyper lnks in a repeater control dynamially
using the onItemBound event, as under, but cannot seem to understand how to
alter the properties to do that.

<asp:HiddenField ID="maxFrequency" runat="server" />

<ASP:Repeater id="repTags" runat="server" OnItemDataBound="ShowFrequery" >

<ItemTemplate>

<a id="lnkFeedTags" href='<%# "../resources/showentries.aspx?strTag=" +
Server.UrlEncode((((DataRowView)Container.DataItem )["sTag"]).ToString())%>'
runat="server" ><%# DataBinder.Eval(Container.DataItem,
"sTag").ToString()%></a>

<asp:HiddenField ID="lnkFeedFrequency" runat="server" Value='<%#
DataBinder.Eval(Container.DataItem, "nTagsCount").ToString()%>'/>

</ItemTemplate>

</ASP:Repeater>

Code behind is

public void ShowFrequery(Object sender, RepeaterItemEventArgs e)

{

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)

{

string strValue =
((HiddenField)e.Item.FindControl("lnkFeedFrequency ")).Value;

string strMax = maxFrequency.Value;

if ((strValue != "") && (strMax != ""))

{

string strSize = string.Empty;

int frqSize = (int.Parse(strValue) / int.Parse(maxFrequency.Value)) * 7;

switch (frqSize)

{

case 1: strSize = "x-small";

break;

case 2: strSize = "small";

break;

case 3: strSize = "smaller";

break;

case 4: strSize = "medium";

break;

case 5: strSize = "larger";

break;

case 6: strSize = "large";

break;

case 7: strSize = "x-large";

break;

default: strSize = "x-small";

break;

}

Style s = new Style();
((HyperLink)e.Item.FindControl("lnkFeedTags")).Mer geStyle(string) =
"font-size:" + strSize;

}
}

}

Thanks a lot,

Imran.

Nov 19 '05 #2
Thanks Clint Hill, that was a quick and good solution, worked great thanks.

Imran.

"Clint Hill" <cl********@nospamath3osoftware.com> wrote in message
news:CE**********************************@microsof t.com...
I would look to change the name of the CSS class the link uses, then setup
CSS classes with these different styles, rather than use MergeStyle.
--
Clint Hill MCAD
H3O Software
http://www.h3osoftware.com
"Imran Aziz" wrote:
Hello All,

I want to change the size of my hyper lnks in a repeater control
dynamially
using the onItemBound event, as under, but cannot seem to understand how
to
alter the properties to do that.

<asp:HiddenField ID="maxFrequency" runat="server" />

<ASP:Repeater id="repTags" runat="server" OnItemDataBound="ShowFrequery"
>


<ItemTemplate>

<a id="lnkFeedTags" href='<%# "../resources/showentries.aspx?strTag=" +
Server.UrlEncode((((DataRowView)Container.DataItem )["sTag"]).ToString())%>'
runat="server" ><%# DataBinder.Eval(Container.DataItem,
"sTag").ToString()%></a>

<asp:HiddenField ID="lnkFeedFrequency" runat="server" Value='<%#
DataBinder.Eval(Container.DataItem, "nTagsCount").ToString()%>'/>

</ItemTemplate>

</ASP:Repeater>

Code behind is

public void ShowFrequery(Object sender, RepeaterItemEventArgs e)

{

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)

{

string strValue =
((HiddenField)e.Item.FindControl("lnkFeedFrequency ")).Value;

string strMax = maxFrequency.Value;

if ((strValue != "") && (strMax != ""))

{

string strSize = string.Empty;

int frqSize = (int.Parse(strValue) / int.Parse(maxFrequency.Value)) * 7;

switch (frqSize)

{

case 1: strSize = "x-small";

break;

case 2: strSize = "small";

break;

case 3: strSize = "smaller";

break;

case 4: strSize = "medium";

break;

case 5: strSize = "larger";

break;

case 6: strSize = "large";

break;

case 7: strSize = "x-large";

break;

default: strSize = "x-small";

break;

}

Style s = new Style();
((HyperLink)e.Item.FindControl("lnkFeedTags")).Mer geStyle(string) =
"font-size:" + strSize;

}
}

}

Thanks a lot,

Imran.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: TheKeith | last post by:
I don't know much about javascript, so take it easy on me. Is there a way to dynamically change a CSS layers dimensions on the fly. Here is what I'm doing. I have a bunch of thumbnails that when...
4
by: Tim_Mac | last post by:
hi, i have a list of hyperlinks (server-side generated), that have a href value as follows: href="javascript:AsyncRequest('someurl.asmx?..',this)" since the url is loaded asynchronously, i need...
1
by: Robbo | last post by:
Hello, I created a datagrid with a few hyperlink columns.. How do i change the color of the hyperlink itself? BLUE is a bit bad on my datagrid color scheme. Thanks, Rob
2
by: Robson Carvalho Machado | last post by:
Dear friends, I'm dynamically creating a Hyperlink with spacer.gif as ImageURL that is an 1px transparent image only to determine link position, but as I create this link dynamically I could not...
9
by: RA | last post by:
While dynamically creating the table; I am adding a hyperlink as a TableCell where text is "Delete". Initially it is disabled and if a checkbox is selected from a table then it gets enabled. Even...
4
by: Tomek R. | last post by:
Hello ! This post does'nt regard column hyperlink. I just have single hyperlink and want to create it's NavigateUrl dynamically. This is my test page <form id="Form1" method="post"...
3
by: sloesch | last post by:
I am working with VS.net 2003, framework 1.1, developing with VB.net, and ASP.net, and I would like to know how you can create a dynamic hyperlink on the fly to a document stored in a SQL database?...
0
by: =?Utf-8?B?Um9nZXI=?= | last post by:
In my app I would like to change the color of the hyperlink from blue to purple when a user clicks the hyperlink in a RichTextBox. The DetectUrls property is set to True and I handle the...
8
by: webster5u | last post by:
Hi, I'm encounter a problem here. I hope somebody able helping me. i'm put a "log out" hyperlink overlap a image and that particular image is inside a table cell. I also try align the hyperlink on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.