CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > microsoft_downloads.css_friendly_control_adapters Tags:
Item Type: NewsGroup Date Entered: 8/3/2006 8:17:41 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 33 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
nickfoster
Asp.Net User
Adapter for single control - radiobutton8/3/2006 8:17:41 AM

0/0

I am looking to create an adapter for a single control, in this case a radiobutton, so that I can override one of its attributes.  I am looking to override the output of the GroupName property so that I can use the radiobutton in gridviews and actually have it function as intended.

Because my page is using a master page, any radiobutton I place in my gridview is renamed with a unique name and so do not function in a group.  If i give my radiobutton a GroupName of "myGroup" it is renamed "ctl00$cphMain$Wizard1$gvPackages$ctl02$myGroup" which is not very helpful.

I am new to Control Adapters and so far I have looked through the example files to try and work out the best approach.

Is there a way to obtain the html that would be rendered by the standard control and then modify it by replacing part of the html string or am I stuck with writing all the html output myself to completely replace the rendering of the control? ( I tried calling Control.Render but obviously this dissapears into an infinite loop.)  Am I going to have to inspect every property of the Control and rewrite the html in the RenderContent function?

Sorry for the basic questions but all the examples are of complex compound controls and I can't find an example of just rendering a single simple control.

Cheers,
Nick
nickfoster
Asp.Net User
Adapter for single control - radiobutton - viewstate problem8/3/2006 2:26:40 PM

0/0

Below is the code as I have it so far.  This seems to render the radiobutton ok but state of the control is not persisted in the viewstate.  Should this maintain state itself or am I going to have to manually add some code to maintain viewstate as well?

************************************************************************
Imports System
Imports System.Data
Imports System.Collections
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Namespace CSSFriendly
 
Public Class RadioButtonAdapter
   
Inherits System.Web.UI.WebControls.Adapters.WebControlAdapter

   
Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)
     
Dim rb As RadioButton = CType(Control, RadioButton)
     
If Not IsNothing(rb) AndAlso rb.Visible Then
        writer.WriteBeginTag(
"input")
        writer.WriteAttribute(
"type", "radio")
        writer.WriteAttribute(
"id", rb.UniqueID)
        writer.WriteAttribute(
"name", rb.GroupName)
        writer.WriteAttribute(
"value", rb.ID)
       
If rb.CssClass <> String.Empty Then
          writer.WriteAttribute(
"class", rb.CssClass)
       
End If
       
If rb.Checked Then
          writer.WriteAttribute(
"checked", "checked")
       
End If
       
If rb.Enabled = False Then
          writer.WriteAttribute(
"disabled", "disabled")
       
End If
       
If rb.ToolTip <> String.Empty Then
          writer.WriteAttribute(
"title", rb.ToolTip)
       
End If
       
If rb.AccessKey <> String.Empty Then
          writer.WriteAttribute(
"accesskey", rb.AccessKey)
       
End If
        writer.Write(HtmlTextWriter.SelfClosingTagEnd)
     
End If
    End Sub

    Protected Overrides Sub RenderBeginTag(ByVal writer As System.Web.UI.HtmlTextWriter)
     
' Write the label if the Text attribute is set and TextAlign=Left
     
Dim rb As RadioButton = CType(Control, RadioButton)
     
If rb.Visible AndAlso rb.Text <> String.Empty AndAlso rb.TextAlign = TextAlign.Left Then
        writer.WriteBeginTag(
"label")
        writer.WriteAttribute(
"for", rb.UniqueID)
        writer.Write(HtmlTextWriter.TagRightChar)
        writer.Write(rb.Text)
        writer.WriteEndTag(
"label")
     
End If
    End Sub


   
Protected Overrides Sub RenderEndTag(ByVal writer As System.Web.UI.HtmlTextWriter)
     
' Write the label if the Text attribute is set and TextAlign=Right
     
Dim rb As RadioButton = CType(Control, RadioButton)
     
If rb.Visible AndAlso rb.Text <> String.Empty AndAlso rb.TextAlign = TextAlign.Right Then
        writer.WriteBeginTag(
"label")
        writer.WriteAttribute(
"for", rb.UniqueID)
        writer.Write(HtmlTextWriter.TagRightChar)
        writer.Write(rb.Text)
        writer.WriteEndTag(
"label")
     
End If
    End Sub

  End Class
End Namespace

2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
computing projects in visual basic.net Authors: Derek Christopher, Pages: 288, Published: 2003
Broadband Bible: Desktop Authors: James E. Gaskin, Pages: 614, Published: 2004
Linux for Windows Addicts: A 12-step Program for Habitual Windows Users Authors: Michael Joseph Miller, Pages: 414, Published: 2000
The A+ Certification and PC Repair Handbook Authors: Christopher A. Crayton, Joel Rosenthal, Kevin Irwin, Pages: 888, Published: 2004
Windows Server 2003 Networking Recipes: A Problem-solution Approach Authors: Robbie Allen, Laura E. Hunter, Bradley J. Dinerman, Pages: 417, Published: 2006
DNS and BIND Authors: Paul Albitz, Cricket Liu, Pages: 601, Published: 2001
C#. NET Illuminated Authors: Art Gittleman, Pages: 500, Published: 2004
Open Source Solutions for Small Business Problems Authors: John Locke, Pages: 556, Published: 2004
Java Design Patterns: A Tutorial Authors: James William Cooper, Pages: 329, Published: 2000
MCSA Managing a Windows 2000 Network Environment Study Guide: Exam 70-218 Authors: Rory McCaw, Alan Simpson, Pages: 656, Published: 2002

Web:
Adapter for single control - radiobutton - ASP.NET Forums I am looking to create an adapter for a single control, in this case a radiobutton, so that I can override one of its attributes. ...
CSS Friendly Control Adapters - ASP.NET Forums Adapter for single control - radiobutton by nickfoster. No Status ... TreeView CRASHES with ERROR when used with the Wizard control by yousaid. No Status ...
CSS Friendly Control Adapters - Discussions The adapter redefines the layout of the RadioButtonList Control. .... and want to display a GridView control grouped by these categories with a single table ...
Configuring Windows 9x/ME for University Network One is a Dial-Up Adapter for a modem, which might or might not be present on your .... Ensure that the radio button Share-level access control is checked. ...
[2008] Enable/disable network adapter with radiobuttons - VBForums [2008] Enable/disable network adapter with radiobuttons Visual Basic . ... User Control Panel, Private Messages, Subscriptions, Who's Online ...
ControlAdapter.LoadAdapterControlState Method (System.Web.UI.Adapters) Loads adapter control state information that was saved by ... a group of RadioButton controls might render as a single view on desktop computer browsers. ...
Broadcom Advanced Control Suite: Broadcom Gigabit Ethernet Adapter ... Click the Remove radio button and click Next. The Confirm File Deletion screen will .... adapter (bundling multiple adapters to look like a single adapter). ...
Windows NT 4.0 Setup Instructions This can be done by clicking on the Add... button located in the Adapter tab of the Network Control Panel and selecting your particular "Network Card" from ...
Download free ASP templates - Free ASP Templates. Likewise, the accesskey for a radio button or checkbox simply toggles its state. This kit's membership control adapters programmatically set the accesskey ...
BIPAC-5100S ADSL Modem/Router with Single Ethernet Port Only use the power adapter that comes with the package. Using. a different voltage rating power ... Go to Start / Settings / Control Panel. In the Control ...




Search This Site:










masterpages, defaultfocus, and development server (help!)

registration module

display title of page being displayed

how to deploy ibuyspy through a 3rd paty host

images - serious problem?

install problems with 3.0 - using msde as the dataabse engine

form authentication on remote machines

(resolved) enable securitytrimming on all sitemap providers

strange bug when change currency to try

searching for bug fixes in this forum

dnn4 upgrade problem - all module missing

windows mdi child toolstrip buttons not merging with parent mdi form toolstrip

dnn web farm system architecture

authentication via webservices (multiple domain url)

how to add a linking for the tabscript?

urlreferrer - goes back?

please recommend xhtml-friendly html wysiwyg controls

please help on vs 2005 publish website

hide modules to choose?

"not a object" in dnn -- is it bug or ?????

quick guide to dnn2/dnn3 installation using separate sql server

new skin problem

login code help.

dnn support for web 2.0 ?

forms authentication (iframe issue)

error when installing asp.net portal using prtl.exe

skins?

solution file syntax for web application projects

host account setup problem

what is the property setdesignmodestate on the control class?

 
All Times Are GMT