Asp.net front-end js and back-end get the control in FormView. Take TextBox as an example, formviewtextbox
I. Foreground js gets the control in FormView
Js to get the front-end control ID, such as TextBox (set its ID to TextBox1 here), we all know that it is a document. getElementById ("<% = TextBox1.ClientID %>"), but if the control is placed in FormView, this cannot be obtained, and an error is reported, prompting that TextBox1 cannot be found. In this case, to obtain the TextBox ID, use the following statement:
Document. getElementById ('<% = FormView1.FindControl ("TextBox1"). ClientID %>. (Note: Here FormView1 is the ID of FormView)
2. Obtain controls in FormView in the background
The background call is similar to the foreground call, as shown below:
TextBox TextBox1 = FormView1.FindControl ("TextBox1") as TextBox;
FindControl () is a server Control with the specified id parameter found in the current named container. It is of the Control type, and as TextBox converts the Control found to the desired type, in this example, TextBox is used.
You can also use the following method: TextBox TextBox1 = (TextBox) FormView1.FindControl ("TextBox1 ");