ASP.NET
  Home arrow ASP.NET arrow Create form Wizard using Visual Studio.NET
Iron Speed
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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 / 5
    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

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    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!


    NEW! Build Web services with transport-level security using Rational Application Developer V7, Part 1: Build Web services and Web services clients

    Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services.
    FREE! Go There Now!


    NEW! Download a free trial of Lotus Quickr 8.0

    Visit IBM developerWorks to download a free trial version of Lotus Quickr 8.0, which enables collaboration by transforming the way everyday business content such as documents, rich media, photos, and video can be shared. Lotus Quickr makes it faster and easier to share content of all types (not just documents) within virtual teams. It is designed to make it easier to collaborate across organizational boundaries, while continuing to work within the context of familiar desktop applications.
    FREE! Go There Now!


    NEW! Hello World: Monitor a simple business process using WebSphere Business Monitor V6.0.2

    This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product.
    FREE! Go There Now!


    NEW! IBM Rational Systems Development e-Kit

    As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br />
    FREE! Go There Now!


    NEW! Rational Talks to You: Manage RUP-based CMMI initiatives

    Join this Rational Talks to You teleconference on December 4 at 1:00 pm ET to discuss how Rational Method Composer can help meet your compliance objectives. Get your questions answered!
    FREE! Go There Now!


    NEW! Rational Testing eKits

    Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing.
    FREE! Go There Now!


    NEW! Run your first CICS application on a PC using TXSeries for Windows

    Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1.
    FREE! Go There Now!


    NEW! Successful Change and Release Management for .NET

    Join this webcast to discover the key requirements for successful change and release management. Learn how to extend your .NET environment to improve productivity and collaboration, and address core problems afflicting team development. In this webcast, we’ll review typical challenges faced by customers and how to resolve them with the IBM Rational Change and Release Management solution, including Rational ClearCase, Rational ClearQuest and Rational Build Forge. Replay is available for 9 months.
    FREE! Go There Now!


    NEW! Understanding Web application security challenges

    As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security.
    FREE! Go There Now!


    NEW! Webcast: Application security testing and Web compliance

    Join the IBM Watchfire team for an informative discussion on techniques and best practices to proactively manage Web application security and how to effectively build application security testing into the software development lifecycle (SDLC). In this Software Delivery Platform webcast you will learn: How to better understand potential web application security vulnerabilities, best practices and how to effectively integrate application security testing into the software development lifecycle, the importance of detecting and removing software vulnerabilities during application development.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP.NET ARTICLES

    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...
    - Order-Related Modules for an ASP.NET AJAX Se...
    - User and Role Management for an ASP.NET AJAX...
    - Programming an ASP.NET AJAX Server-Centric B...

    IBM developerWorks




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway