Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2005, 09:19 AM
Registered User
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic ASP button generation

I am trying to dynamically generate HTML content with VB in ASP.NET. Everything is wonderful except for the <asp:Button> which does not appear. I have read that I need to create an object and add it to the page. Sounds great except except I haven't found an example give me a more explicit idea of what to do. Any help would be greatly appreciated, code is included below.

"I'm stupid. You're smart. I was wrong. You were right. You're the best. I'm the worst. You're very good-looking. I'm not very attractive." - Happy Gilmore

<body bottomMargin="400" leftMargin="0" topMargin="0" onload="resizeTo(document.body.scrollWidth,documen t.body.scrollHeight)"
rightMargin="0" MS_POSITIONING="GridLayout">
   <%
   Dim Func As Integer
   Func = Request("Func")
   if Func <> 2 Then
        Func = 1
   End if
   Select Case Func
   Case 1
         Response.Write("<form runat='server' enctype='multipart/form-data' ID='Form1' ACTION='report.asp?func=2'>")
         Response.Write("<table align='center' cellspacing='2' cellpadding='2'>")
         Response.Write("<tr><td colspan='2'><H2>Report</H2></td></tr>")
         Response.Write("<tr><td>Main File</td><td><input type='file' runat='server' id='namefile' NAME='namefile' /></td></tr>")
         Response.Write("<tr><td>G1 File</td><td><input type='file' runat='server' id='g1file' NAME='g1file' /></td></tr>")
         Response.Write("<tr><td>I File</td><td><input type='file' runat='server' id='ifile' NAME='ifile' /></td></tr>")
         Response.Write("<tr><td>G2 File</td><td><input type='file' runat='server' id='g2file' NAME='g2file' /></td></tr>")
         Response.Write("<tr><td colspan='2' align='center'><asp:Button ID='cmdCheck' Text='Check' runat='server' OnClick='check' /><input type=""reset"" /></td></tr></table>")
         Response.Write("<asp:datagrid ID='DataGrid1' runat='server'></asp:datagrid>")
         Response.Write("<asp:label ID='l1' runat='server'></asp:label></form>")

       Case 2
          Response.Write ("Case 2")
   Case Else
          Response.Write("oh no")
       End Select %>

</body>


 
Old May 18th, 2005, 09:32 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is a completely incorrect approach to ASP.NET.

You can't Response.Write HTML that outputs markup of ASP.NET controls. The control markup has to be parsed by the ASP.NET process. By doing what you are trying to do you are sending HTML to the browser that looks like this:

   <asp:button...>

The browser how no idea how to deal with this so it just ignores it. I think you need to go back to the beginning and get an understanding of the basics of how ASP.NET works.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic generation of .Net button in a position sonaldewle General .NET 0 April 3rd, 2006 03:51 AM
Dynamic generation of asp.net server controls shashi1312 Classic ASP XML 1 August 2nd, 2005 04:52 AM
Dynamic ASP button generation Lloyd_Christmas Classic ASP Basics 1 May 17th, 2005 06:50 PM
Dynamic Button Generation LouMattera BOOK: Professional C#, 2nd and 3rd Editions 2 March 4th, 2005 04:26 PM
Dynamic generation of controls in ASP.NET Maxood ASP.NET 1.0 and 1.1 Basics 2 March 8th, 2004 07:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.