Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 16th, 2008, 03:47 AM
Registered User
Join Date: Apr 2008
Location: tehran, tehran, Iran.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add textbox in cs file

 i copied these codes from "Wrox-Professional Web Parts and Custom Controls with ASP.NET" to my cs.File
protected override void CreateChildControls()
        //LiteralControl=represent html elements,html and other strings in asp.net page that don't requared procesing on the server
        LiteralControl lt;
        System.Web.UI.WebControls.TextBox txt = new TextBox();
        lt = new LiteralControl("<b>Value: ");

        txt.Text = "Hello,world";
        txt.ID = "txtInput";

        lt = new LiteralControl("</b>");
but , i saw this error:
Control 'txtInput' of type 'TextBox' must be placed inside a form tag with runat=server


  #2 (permalink)  
Old April 25th, 2008, 02:23 AM
Registered User
Join Date: Apr 2008
Location: delhi, delhi, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

These are the steps to make you learn that how can you add run time controls with different values.

First when You created
 lt = new LiteralControl("<b>Value: "); means you are instantiating a new literal control

 lt = new LiteralControl("</b>");
is to show you that you can change values dynamically

If you want to add another literal control then declare another object name such as
Literal Control obj = new literal COntrol();
obj.text="&lt value";

  #3 (permalink)  
Old April 30th, 2008, 02:37 PM
Authorized User
Join Date: Jun 2007
Location: Christchurch, , New Zealand.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hericles

You may have simply missed out the <form runat=server> tag as well. That error message means the controls you have placed on the page aren't wrapped between <form runat=server> and </form> tags. ASP.Net controls need the runat=server element to function properly if they are to run on the server rather than the client.


"I will prepare and one day my chance will come."

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyboard shortcut to go from cs to aspx file roman BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 June 20th, 2008 01:28 PM
how to call .cs file into another application ravi_bachwala ASP.NET 1.0 and 1.1 Basics 0 June 19th, 2007 07:30 AM
SQL in .cs file the_dude ADO.NET 2 January 27th, 2007 04:37 AM
Page reference in cs file jacob ASP.NET 1.0 and 1.1 Basics 1 July 22nd, 2003 10:37 PM

All times are GMT -4. The time now is 11:35 PM.

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