Library tutorials & articles

Make your Classic ASP code work like in ASP.NET

RadioButton Example

<!--#Include File = "..\WebControl.asp"        -->
<!--#Include File = "..\Server_LinkButton.asp" -->
<!--#Include File = "..\Server_CheckBox.asp" -->
<!--#Include File = "..\Server_RadioButton.asp" -->
<!--#Include File = "..\Server_Label.asp"    -->
<!--#Include File = "DBWrapper.asp"    -->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>CheckBox and CheckBoxList Example</TITLE>
<LINK rel="stylesheet" type="text/css" href="Samples.css">
</HEAD>
<BODY>
<!--#Include File = "Home.asp"        -->
<%
    Call Main()
%>   
<Span Class="Caption">CHECKBOX EXAMPLES</Span>
<span><br>AutoPostBack = True is used for this example...</span>
<!--#Include File = "..\FormStart.asp"        -->
    <%lblMessage%><HR>
    <%chkHideShow%> | <%chkTableLayOut%> | <%chkHorizontalDirection%> | <%chkShowGrid%><HR>
    <%optRadioList%>
    <HR>
    <%cmdAdd%> | <%cmdRemove%> | <%cmdAddColumnOrRow%> | <%cmdRemoveColumnOrRow%>
<!--#Include File = "..\FormEnd.asp"        -->
</BODY>
</HTML>
<%  'This would normaly go in a another page, but for the sake of simplicity and to minimize the number of pages
    'I'm including code behind stuff here...
    Dim lblMessage
    Dim cmdAdd
    Dim cmdRemove
    Dim cmdAddColumnOrRow
    Dim cmdRemoveColumnOrRow
   
    Dim chkHideShow
    Dim chkTableLayOut
    Dim chkHorizontalDirection
    Dim optRadioList
    Dim chkShowGrid
   
    Page.DebugEnabled = False
   
    Public Function Page_Init()
        Set lblMessage = New_ServerLabel("lblMessage")
        Set cmdAdd = New_ServerLinkButton("cmdAdd")
        Set cmdRemove = New_ServerLinkButton("cmdRemove")               
        Set cmdAddColumnOrRow = New_ServerLinkButton("cmdAddColumnOrRow")
        Set cmdRemoveColumnOrRow = New_ServerLinkButton("cmdRemoveColumnOrRow")               
       
        Set chkHideShow = New_ServerCheckBox("chkHideShow")
        Set chkHorizontalDirection  = New_ServerCheckBox("chkHorizontalDirection")
        Set chkTableLayOut = New_ServerCheckBox("chkTableLayOut")
        Set optRadioList = New_ServerRadioButtonList("optRadioList")
        Set chkShowGrid  = New_ServerCheckBox("chkShowGrid")
        optRadioList.AutoPostBack=true
    End Function
    Public Function Page_Controls_Init()                       
        cmdAdd.Text = "Add"
        cmdRemove.Text = "Remove"
        cmdAddColumnOrRow.Text = "Add Column"
        cmdRemoveColumnOrRow.Text = "Remove Column"
        lblMessage.Control.Style = "border:1px solid blue;background-color:#EEEEEE;width:100%;font-size:8pt"       
        lblMessage.Text = "This is an Example"
        chkHideShow.Caption = "Hide/Show List"
        chkHideShow.AutoPostBack = True
       
        chkTableLayOut.Caption = "Table Layout"
        chkTableLayOut.Checked = True
        chkTableLayOut.AutoPostBack = True
       
        chkHorizontalDirection.Caption = "Horizontal Flow"
        chkHorizontalDirection.AutoPostBack=True
       
        chkShowGrid.Caption = "Show Grid"
        chkShowGrid.AutoPostBack = True
       
        optRadioList.DataTextField = "TerritoryDescription"
        optRadioList.DataValueField = "TerritoryID"
        Set optRadioList.DataSource = GetRecordset("SELECT TerritoryID,TerritoryDescription FROM Territories ORDER BY 2")       
        optRadioList.DataBind() 'Loads the items collection (that will stay in the viewstate)...
        Set optRadioList.DataSource = Nothing 'Clear
        optRadioList.RepeatColumns=4       
    End Function
   
    Public Function Page_PreRender()
        Dim msg
        Set msg = New StringBuilder
        msg.Append "chkHideShow Is checked? " & chkHideShow.Checked & "<BR>"
        msg.Append "<B>RepeatColumns:  </B>" & optRadioList.RepeatColumns &  "<BR>"
        msg.Append "<B>RepeatLayOut:  </B>" & optRadioList.RepeatLayOut &  "<BR>"
        msg.Append "<B>RepeatDirection:  </B>" & optRadioList.RepeatDirection  &  "<BR>"
        msg.Append "<B>SelectedValue:  </B>" & optRadioList.Items.GetSelectedValue  &  "<BR>"
        msg.Append "<B>SelectedText:  </B>" & optRadioList.Items.GetSelectedText  &  "<BR>"
        msg.Append "<HR>"       
        lblMessage.Text  = msg.ToString()
    End Function
    Public Function chkHideShow_Click()
        optRadioList.Control.Visible = Not optRadioList.Control.Visible
    End Function
   
    Public Function chkTableLayOut_Click()
        If  chkTableLayOut.Checked  Then
            optRadioList.RepeatLayout = 1           
        Else
            optRadioList.RepeatLayout = 2
        End If       
    End Function
    Public Function chkShowGrid_Click()
        If  chkShowGrid.Checked  Then
            optRadioList.BorderWidth = 1
        Else
            optRadioList.BorderWidth=0
        End If       
    End Function
    Public Function chkHorizontalDirection_Click()
        If  chkHorizontalDirection.Checked  Then
            optRadioList.RepeatDirection=1
        Else
            optRadioList.RepeatDirection = 2
        End If       
       
    End Function
    Public Function cmdAdd_OnClick()
        optRadioList.Items.Add optRadioList.Items.Count,optRadioList.Items.Count,False
    End Function
    Public Function cmdRemove_OnClick()
        optRadioList.Items.Remove optRadioList.Items.Count-1
    End Function
   
    Public Function cmdAddColumnOrRow_OnClick()
            optRadioList.RepeatColumns = optRadioList.RepeatColumns  + 1
    End Function
    Public Function cmdRemoveColumnOrRow_OnClick()
        If optRadioList.RepeatColumns - 1 >0 Then
            optRadioList.RepeatColumns = optRadioList.RepeatColumns -1
        End If
    End Function
   
%>

Comments

  1. 14 Apr 2009 at 20:39
    Wow. The Sample code is great. Used the example to display a section of a database to test. Took only long enough to write the SQL code. Wish you had a list of **all ** the features that could be tweaked.. Have been playing with sizes, shapes, colors etc..
  2. 13 Aug 2008 at 14:30

    Hi. I have several ASP 3.0 to EXCEL 10.0 reports thaqt work fine. When I try to go to EXCEL 11.0, I get an invalid class.  How do I set that up for my object?

     

    Thanks,Mac Kimsey mackimsey@yahoo.com

  3. 14 Jun 2004 at 10:29
    Check out the sample site at:

    http://clasp.csharpjunkie.com/
  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Make your Classic ASP code work like in ASP.NET.

Leave a comment

Sign in or Join us (it's free).

Christian Calderon

Related podcasts

  • Developer's Guide to IIS7

    Steve Schofield is an IIS expert working for webhost ORCS Web. Steve and his team are responsible for such sites as Channel9, ASP.NET, weblogs.asp.net and ASP Alliance. As a member ASP Insiders and a IIS MVP - Steve knows his way around a web server. Steve sheds light on how the new features in I...

Events coming up

  • Mar 15

    DevWeek 2010

    London, United Kingdom

    DevWeek is Europe’s leading independent conference for software developers, database professionals and IT architects, and features expert speakers on a wide range of topics, including .NET 4.0, Silverlight 3, WCF 4, Visual Studio 2010, REST, Windows Workflow 4, Thread Synchronization, ASP.NET 4.0, SQL Server 2008 R2, LINQ, Unit Testing, CLR & C# 4.0, .NET Patterns, WPF 4, F#, Windows Azure, ADO.NET, Entity Framework, Debugging, T-SQL Tips & Tricks, and more.

We'd love to hear what you think! Submit ideas or give us feedback