We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add another text box programatically on a textchanged evnt of a text box in a place holder

Thread ID:

Created:

Platform:

Replies:

52497 Nov 29,2006 02:54 PM UTC ASP.NET Web Forms (Classic) 0
loading
Tags: FAQ
Rajesh
Asked On November 29, 2006 02:54 PM UTC

Please give a solution for me for the following code. here i have a text box already after that when a text box value is changed and a new textbox will come in the place holder with postback property=true. After that when iam typing a value in that textbox (new one) and pressing the tab then the form will postback. but me want a new text box will generate there as the first text box textchanged event. how can me resolve the prob. Please help me

test.aspx
***************
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb" Inherits="partyroute.test"%>



test







cellPadding="1" width="300" border="1">














***************************
test.vb
************
Public Class test
Inherits System.Web.UI.Page

Dim k As Integer = 2

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
Private Sub InitializeComponent()

End Sub
Protected WithEvents a1 As System.Web.UI.WebControls.TextBox
Protected WithEvents ph As System.Web.UI.WebControls.PlaceHolder
Protected WithEvents lb As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.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

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then
ViewState("prd") = 1
lb.Text = ViewState("prd")
Else
If ViewState("prd") > 1 Then
For k = 2 To ViewState("prd")
addfds(k)
lb.Text = "hai"
Next
End If
'lb.Text = ViewState("prd")
End If
End Sub

Sub addfds(ByVal s As String)
Dim txt As TextBox

txt = New TextBox
txt.ID = "a" & s
txt.AutoPostBack = True
'txt.Text = "a" & s
ph.Controls.Add(txt)
ph.Controls.Add(New LiteralControl("
"))
End Sub

Private Sub a1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles a1.TextChanged
ViewState("prd") = ViewState("prd") + 1
addfds(ViewState("prd"))
End Sub
End Class

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;