You are not using the ASP.NET way. In ASP.NET, we use web controls like the 
TextBox and RequiredFieldValidator. You can create these and any HTML you like 
through web controls. For example, if you wanted a string representing "</td>", 
you would use a LiteralControl("</td>").
  You also don't output the HTML of a form yourself in ASP.NET. (Sure, you can, 
but the webform concept already adds a <form> tag, which is also its own web 
control (because it has runat=server).
  A short tutorial.
  1. Create a web form (aspx) file with the <html><head><body> and <form> tags. 
<form> should have runat=server.
  2. Add a <asp:PlaceHolder id="PlaceHolder1" runat="server" > inside the 
<form> where you want your dynamic code.
  3. Define the Page_Load method. In the Page_Load method, create each control 
and add it to the PlaceHolder. Its as easy as this:
   
  Dim vTextBox As TextBox = New TextBox()
vTextBox.ID = "TextBox1"
PlaceHolder1.Controls.Add(vTextBox)
   
   strongly recommend that you go through the tutorials on any site and read 
articles on the web about creating controls dynamically.

Dean Fiala <[EMAIL PROTECTED]> wrote:
  Since you are generating the form dynamically in this way, you are
outside the ASP.NET control model, and you'll need to also dynamically
generate the validation.

ASP.NET ultimately renders HTML text and client-side scripts, so one
way to figure out what you need to create for the validation is to
create the page using standard asp.net controls along with the
validators you want to use and see what it ends up rendering to the
client.  You can then see what you would need to add to your output to
validate the controls on the client side.

You'll need to create your own server-side validation as well on the
form-variables returned by the postback.

All of this is going to be A LOT OF WORK.  Your time might be better
spent by actually adding the ASP.NET controls and their associated
validators dynamically to the page and taking better advantage of the
infrastructure built into ASP.NET instead of using it as a simple HMTL
generator.



On 3/14/06, shyms05 <[EMAIL PROTECTED]> wrote:
> hi to all,
>
> i want to put validation in a text field, but it is generated
> dynamically.here's the code
>
> it's in the code behind
>
>   Response.Write("<form action=add.aspx method=post name=frm1  >")
>
>   Response.Write("<tr>")
>   Response.Write("<td>")
>   Response.Write
> ("Quantity:")
>  Response.Write("</td>")
>
>  Response.Write("<td>")
>  Response.Write("<input type=text name=txtqty size=5 >")
>  Response.Write("</td>")
>  Response.Write("</tr>")
>
>  Response.Write("<tr>")
>  Response.Write("<td>")
>  Response.Write("</td>")
>  Response.Write("<td>")
>  Response.Write("<input type=submit name=submit value=Add_to_Cart
> STYLE=background-color:5475B2;font-size:8pt;color:ffffff >")
>  Response.Write("</td>")
>  Response.Write("</tr>")
>  Response.Write("</table>")
>
> how can i input validation in it?

Kamran Shahid
Software Engineer (MCSD.Net)
Progressive Systems (Pvt) Ltd
Karachi,Pakistan
Tel   :92-21-5675294-96
Cell  :92-0304-2212616
Email :[EMAIL PROTECTED] 
      :[EMAIL PROTECTED]
                
---------------------------------
Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 

[Non-text portions of this message have been removed]





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNet2/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to