ASP.NET
  Home arrow ASP.NET arrow Create form Wizard using Visual Studio.NET
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Create form Wizard using Visual Studio.NET
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 6
    2001-12-05

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Create form Wizard using VS.NET

    This is a updated demo to create form wizard using an Visual Studio.NET

    <%@ Page Language="vb" EnableSessionState="False"EnableViewState="True" Trace="False" Debug="False"Strict="True" CodeBehind="createformcode.aspx.vb"AutoEventWireup="false" Inherits="aspfree.createformcode" %>
    <HTML>
    <HEAD>
    <title></title></SCRIPT>
    </HEAD>
    <body bgcolor="#ffffff">
    <form runat="server"id="form1">
    Select a tablename tocreate a .NET form for:
    <asp:dropdownlistid="tblList" runat="server" />&nbsp;&nbsp;
    <asp:Buttonid="GetTable" Text="Get Table" onclick="GetTable_Click"runat="server" />
    <asp:panelid="myPanel" runat="server"visible="false"><BR>Select the
    Columns used for generating the form.
    <asp:datagrid id="MyDataGrid" runat="server"AutoGenerateColumns="False" HeaderStyle-BackColor="#aaaadd"Font-Size="8pt" Font-Name="Verdana" CellPadding="3"BorderWidth="1" BorderColor="black">
    <Columns>
    <asp:TemplateColumnHeaderText="Add?">
    <ItemTemplate>
    <asp:CheckBoxid="chkAdd" runat="server" />
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumnHeaderText="Name" DataField="name" />
    <asp:TemplateColumnHeaderText="Create Validator?">
    <ItemTemplate>
    <asp:CheckBoxid="chkValid" runat="server" />
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid>
    <asp:Button id="Button1" onclick="Button1_Click"runat="server" Text="Create Form"></asp:Button>
    </asp:panel>
    <asp:panelid="pnlTextarea" visible="false" runat="server">
    <P>Copythis code into a new ASP.NET page</P>
    <TEXTAREAid="taResults" rows="40" cols="90"runat="server">&lt;/asp:panel&gt;

    &lt;/form&gt;
    &lt;/body&gt;
    &lt;/html&gt;
    </TEXTAREA>
    </asp:panel>
    </form>
    </body>
    </HTML>

    asdf

    Imports System
    Imports System.Text
    Imports System.IO
    Imports System.Data
    Imports System.Data.SqlClient
    Imports Microsoft.VisualBasic
    Imports System.Configuration

    Public Class createformcode
    Inherits System.Web.UI.Page
    Protected WithEvents tblList As System.Web.UI.WebControls.DropDownList
    Protected WithEvents GetTable As System.Web.UI.WebControls.Button
    Protected WithEvents MyDataGrid As System.Web.UI.WebControls.DataGrid
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    Protected WithEvents myPanel As System.Web.UI.WebControls.Panel
    Protected WithEvents pnlTextarea As System.Web.UI.WebControls.Panel
    Protected WithEvents taResults As System.Web.UI.HtmlControls.HtmlTextArea

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()
    End Sub

    #End Region
    Dim sqlText As String
    Dim ds As New DataSet()
    Dim dbComm As New SqlDataAdapter()
    Dim conn As SqlConnection
    Dim sqlServer As String

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
    sqlServer = GetSqlConn()
    conn = New SqlConnection(sqlServer)


    If Not IsPostBack Then
    sqlText = "select id, name from sysobjects where xtype='U' order by name"
    dbComm = New SqlDataAdapter(sqlText, conn)
    dbComm.Fill(ds, "AllTables")
    tblList.DataSource = ds.Tables("AllTables").DefaultView
    tblList.DataTextField = "name"
    tblList.DataValueField = "name"
    tblList.DataBind()
    End If


    End Sub

    Function CreateValidator(ByVal myName As String) As String
    Dim mySB As StringBuilder = New StringBuilder()

    REM -- use :<some text>: as placeholders
    mySB.Append("<asp:RequiredFieldValidator runat=""server""id="":Name:"" ControlToValidate="":control:""ErrorMessage="":errMsg:""display=""Static"">This RequiredField!</asp:RequiredFieldValidator>")

    mySB.Replace(":Name:", "vld" & myName) 'add the validator name
    mySB.Replace(":control:", "at" & myName) 'add the control name
    mySB.Replace(":errMsg:", myName & " is required")

    Return mySB.ToString()

    End Function


    Function GetSqlConn() As String
    Dim DSN As String = ConfigurationSettings.AppSettings("DSN")
    Return DSN
    End Function


    Sub GetTable_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim sqlText As String
    sqlText = "SELECT syscolumns.name, syscolumns.isnullable FROM sysobjects INNER JOINsyscolumns ON sysobjects.id = syscolumns.id where sysobjects.name = '" &tblList.SelectedItem.Text & "' ORDER BY syscolumns.colid"

    REM -- Connect to SQL
    dbComm = New SqlDataAdapter(sqlText, conn)

    REM -- Fill DataSet
    dbComm.Fill(ds, "TestData")
    MyDataGrid.DataSource = ds.Tables("TestData").DefaultView
    MyDataGrid.DataBind()


    REM -- Show the results
    myPanel.Visible = True

    End Sub


    Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim i As Integer
    Dim _item As DataGridItem
    Dim dr As DataRow
    Dim sb As StringBuilder = New StringBuilder()
    Dim strOutput As String

    REM -- Auto Generate The Form
    sb.Append("<form runat=""server""id=""form2"" name=""form2"">" &Chr(13) & Chr(10))
    sb.Append(" <table border=1>" & Chr(13))


    For i = 0 To MyDataGrid.Items.Count - 1
    REM -- Get the checkbox
    _item = MyDataGrid.Items(i)
    Dim addCheckBox As CheckBox = CType(_item.FindControl("chkAdd"), CheckBox)
    Dim validCheckBox As CheckBox = CType(_item.FindControl("chkValid"), CheckBox)

    If addCheckBox.Checked Then
    sb.Append(" <tr>" & Chr(13))
    sb.Append(" <td>" & _item.Cells(1).Text & "</td>"& Chr(13))
    sb.Append(" <td>")
    sb.Append("<asp:textbox id=""at" & _item.Cells(1).Text &""" runat=""server"" />")

    'create a validator control
    If validCheckBox.Checked Then
    sb.Append(" " & Chr(13) & CreateValidator(_item.Cells(1).Text))
    End If

    sb.Append("</td>" & Chr(13)) '
    sb.Append(" </tr>" & Chr(13)) ' close out the row
    End If

    Next
    sb.Append(" <tr>" & Chr(13)) ' close out the row
    sb.Append(" <td colspan=""2""><asp:buttonid=""button1"" Text=""Validate Form""runat=""Server"" /></td>" & Chr(13))
    sb.Append(" </tr>" & Chr(13)) ' close out the row
    sb.Append(" </table>" & Chr(13))
    sb.Append(Chr(13) & "</form>")
    strOutput = sb.ToString()
    strOutput = System.Web.HttpUtility.HtmlEncode(strOutput)
    taResults.Value = strOutput
    pnlTextarea.Visible = True
    End Sub

    End Class


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP.NET Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    Build Forge Express demo: Enabling software delivery excellence for small and midsized businesses

    This demonstration gives you an overview of IBM® Rational® Build Forge Express Edition, a global offering that provides a framework to automate and execute software processes. Rational Build Forge provides a software assembly line that can support all of your tools, technologies, and platforms so you can achieve a repeatable, reliable, and traceable build and release process.
    FREE! Go There Now!


    NEW! Calling all CC Power Users – and those that would like to be!

    Join this Rational Talks to You teleconference, featuring Paul Boustany and Mark Krasovich, to speak to the experts about becoming a Rational ClearCase power user. Get a chance to ask your questions and learn tips and tricks for using Rational ClearCase in Agile development
    FREE! Go There Now!


    NEW! Achieving True Agility -- How process can change the behavior of your tools

    Achieving true agility is a never-ending effort. We will showcase how you can become agile incrementally, a few practices at the time.Which practices should any agile team strive to adopt? What additional practices should you consider based on your needs to scale? Adopting practices are however made much easier with the right tool support. What about if your tools adapt to your practices? We will take a look at how the Jazz technology can be leveraged to make your process change the behavior of your tools.
    FREE! Go There Now!


    NEW! Download IBM WebSphere Portal V6.1 beta code

    Download the IBM WebSphere Portal V6.1 beta code and learn more about the rich features and enhancements in IBM WebSphere Portal V6.1. WebSphere Portal provides a composite application or business mashup framework and the advanced tooling needed to build flexible, SOA-based solutions, and scalability to meet the needs of any size organization.
    FREE! Go There Now!


    NEW! Hello World: WebSphere Service Registry and Repository

    Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z

    IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Functional Tester V7.0.1

    Get a free trial download of the latest version of IBM Rational Functional Tester V7.0.1. Rational Functional Tester is an automated functional and regression testing solution for QA teams concerned with the quality of their Java, Microsoft Visual Studio .NET, and Web-based applications.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Tester for SOA Quality V7.0.1

    Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services.
    FREE! Go There Now!


    NEW! Webcast: IBM Rational Build Forge - Beyond the Build

    The discipline of assembling and delivering software is maturing beyond standard developer-centric compile/test software builds. The end-to-end software development lifecycle is emerging as the new focus moves “Beyond the Build.” Join this on demand webcast to learn about methods for streamlining software delivery and key capabilities of the IBM Rational Build Forge framework for automating build and release management in environments of any size.
    FREE! Go There Now!


    NEW! Webcast: Quickly provide customized, integrated user interfaces with Lotus Notes 8

    IBM Lotus Notes 8 provides a wide range of developers the ability to provide customized, integrated user interfaces via composite applications and via custom sidebar and toolbar plug-ins. This webcast provides you with tips and techniques to use with out-of-the-box capabilities of Lotus Notes 8, and survey how you can share useful components within your own company and within a larger community.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek