Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: UserControl Probelm

Reply
Thread Tools

Re: UserControl Probelm

 
 
Davide Vernole [MVP]
Guest
Posts: n/a
 
      09-08-2004
Sunil Sabir <(E-Mail Removed)> typed:
> Dear All,
>
> Actually I have a user control which has nine hyperlinks.What I want
> to do is that
> when I add this user control in an .aspx file. It should change the
> color of the first
> hyperlink to BLACK. Below is the code:
>
> In the User Control Layout.ascx
>
> <%@ Register TagPrefix="uc1" TagName="Layout" Src="Layout.ascx" %>
>
> Public Value As System.Drawing.Color
> Public Property valr1Color() As System.Drawing.Color
>
> Get
>
> Return valr1.ForeColor
>
> End Get
>
> Set(ByVal Value As System.Drawing.Color)
>
>
> valr1.ForeColor = Value
> End Set
>
> End Property
>
> In the WebForm.aspx:
>
> Public ctlcontrol As Control
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> ctlcontrol = LoadControl("Layout.ascx")
>
> CType(ctlcontrol, Layout).valr1Color =
> System.Drawing.Color.Black Me.Controls.Add(ctlcontrol)
>
> The problem is that its not changing its color to black in the LOAD
> event of aspx file.
>
> Any help much appreciated.
>
> cheers,
> Sunil Sabir


I suggest to change approach. Why don't you use a CssClass to change color ?
You could use a Css sytelsheet file in your web application and than you
create a class style for the first link.

Change the property in this way:

Public Value As String
Public Property valr1Css() As String
Get
Return valr1.CssClass
End Get
Set(ByVal Value As String)
valr1.CssClass = Value
End Set

End Property

and the Page_load like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ctlcontrol = LoadControl("Layout.ascx")
CType(ctlcontrol, Layout).valr1Css = "myCssClass"
End Sub


--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer


 
Reply With Quote
 
 
 
 
Davide Vernole [MVP]
Guest
Posts: n/a
 
      09-09-2004
Sunil Sabir <(E-Mail Removed)> typed:
> Dear sir,
>
> Thanks for your prompt reply. Is it not possible with this
> approach.Why can't I achieve my task with this code.
>
> Any help much appreciated.
>
> Cheers,
> Sunil Sabir
>



To tell the truth you can set the ForeColor proprerty and it work (I just
test it !). I suggest the other approach because I think that the graphical
style, in a site, it must be set using CSS Stylesheet and not with inline
style or by code.

I tried a simple code:

//C#
this.lnkTest.ForeColor = System.Drawing.Color.DarkSalmon;

and it has worked has expected.

So I suggest you to verify, step by step, your code in debug mode to verify
if you set this property really.

--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer


 
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
Mozilla browser probelm - Pls help kimshapiro100@yahoo.com Firefox 3 03-09-2006 07:10 PM
wireless probelm =?Utf-8?B?YWFyb25zaW1v?= Wireless Networking 1 10-24-2005 09:35 PM
Linksys Probelm Jason Wireless Networking 1 11-24-2004 12:16 AM
PIX Probelm Greg Cisco 3 05-21-2004 02:16 PM
Cisco 1751 Point-to-point probelm. Tom Cisco 2 05-21-2004 01:37 PM



Advertisments