C# .NET - validator code behind

Asked By praveen pubby
29-Oct-10 04:58 AM
  protected void lnkInsert_Click(object sender, EventArgs e)

      {

TextBox name = (TextBox)TextBox.FindControl("name").ToString();   ....is it correct ..??if not ...make it correction
  Jatin Prajapati replied to praveen pubby
29-Oct-10 05:01 AM
protected void lnkInsert_Click(object sender, EventArgs e)

    {

TextBox name = (TextBox)Page.FindControl("name");


or you can directly also access the text box like

string strName = name.Text;
  praveen pubby replied to Jatin Prajapati
29-Oct-10 05:04 AM
for validator ...!!!  i kept validator ..so tht seeking to ryt code beind fr tht ...!!!
  Sagar P replied to praveen pubby
29-Oct-10 06:11 AM
You can access it directly using textbox name and Text property like this;

protected void lnkInsert_Click(object sender, EventArgs e)
{
  string strName = name.Text;


}
  undhad ashwin replied to Sagar P
31-Oct-10 12:32 PM
protected void lnkInsert_Click(object sender, EventArgs e)

    {

TextBox name = (TextBox)Page.FindControl("name").Text;


or you can directly also access the text box like

string strName = name.Text;
Create New Account
help
Hi I want to get server side control in static web methods in c# using page.findcontrol("textbox") Page page = (Page)HttpContext.Current.Handler; Panel ltr = (Panel)page.FindControl("panelID"); but it return null in ltr object. . . . how can i access server side public static string Result( string controlName) { return RenderControl(controlName); } public static string RenderControl( string controlName) { Page page = new Page (); UserControl userControl = ( UserControl )page.LoadControl(controlName); userControl.EnableViewState = false ; HtmlForm form = new HtmlForm
findcontrol in my page p1 = planetlist.SelectedValue.ToString(); foreach (Control page_control in Page.Controls) { foreach (Control c in page_control .Controls) { if (c is TextBox) { if (c = = (TextBox)Page.FindControl("txt1")) { ((TextBox)c).Text = p1.ToString(); } else if (c = = (TextBox)Page.FindControl("TextBox1")) { ((TextBox)c).Text = p1.ToString(); } else if (c = = (TextBox)Page.FindControl("TextBox2")) { ((TextBox
i m adding rows dynamically on add button click using javascript like: name age salary textbox textbox textbox(on add button click) textbox textbox textbox(on add button click) textbox textbox textbox(on add button click) there is also a delete button for each row to
regarding ((TextBox)LoginView1.FindControl("UserName")).Text Can I do string A = (( TextBox )LoginView1.FindControl( "UserName" )).Text ? So, it depends on where you call this line of code. TextBox textBox = (TextBox)LoginView1.FindControl( "UserName" ); if (textBox ! = null ) { string A = textBox.Text; } string A = ""; system.web.UI.webcontrol myControl = loginview1.findcontrol("username"); if ( (myControl ! = null) && (myControl GetType() = = TypeOf(TextBox)) ) a = mycontrol.text; I am still getting same error: Message: Exception of type 'System.Web