Re: Programmatically changing CssStyle on Panels depending on DB values
- From: "JDP@Work" <JPGMTNoSpam@xxxxxxxxxxxxx>
- Date: Wed, 22 Jun 2005 09:00:04 -0700
Sorry that this is VB....
<mattsthompson@xxxxxxxxx> wrote in message
news:1119008553.651307.114810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I am trying to change the look of a panel but only if that panel's ID
> is returned by a database lookup.
>
> I've tried using FindControl but this returns Controls and not
> WebControls and I'm having difficulty converting items.
>
> I'm coding in C#
>
> I was hoping to do something along the lines of:
>
> -- quote --
> Control hControl = Page.FindControl(dr.GetString(4));
>
> hControl.CssStyle = "MenuItemSelected";
> -- end quote --
>
> But the last line doesn't quite work ;o)
>
Sorry this is in VB
Call this on Fill() and/or whenever an event occurs, like a drop down is
selected or whatever....
.....snipit follows
Public Shared Sub SetupDynamicFields(ByVal formName As String, ByVal criteria As
String, ByVal page As Object)
Dim dr As SqlClient.SqlDataReader =
SqlHelper.ExecuteReader(Common.ConnectionString, "usp_GetControl_Info",
formName, criteria)
Do While dr.Read
'.... make vars, get & do stuff
Dim lbl As Label = page.FindControl(lblName)
Dim rfv As RequiredFieldValidator = page.FindControl(rfvName)
Dim tr As HtmlControls.HtmlTableRow = page.FindControl(trName)
If Not lbl Is Nothing Then
If dr.Item("Required") Then
lbl.CssClass = "StdFormLabelRequired"
Else
lbl.CssClass = "StdFormLabel"
End If
End If
'.... setup Required as Enabled to enable any on page validators, a form field
can be visible but not enabled, (read only) or a label.
'..... setup Visiblity
'.... setup entire tr visibility, easy way to dispay or hide form fields on
certain criteria, rather than having an empty tr or a hanging label.
.....snipit end
HTH
JeffP....
.
- References:
- Programmatically changing CssStyle on Panels depending on DB values
- From: mattsthompson
- Programmatically changing CssStyle on Panels depending on DB values
- Prev by Date: RE: check if image or file exists
- Next by Date: RE: Inline Expression Resolution
- Previous by thread: Programmatically changing CssStyle on Panels depending on DB values
- Next by thread: Conditional code in Repeaters
- Index(es):
Relevant Pages
|