Need help in Javascript
-
Hi I created an UserControl, it contains two container controls. First container contains DropDownList1,TextBox1 and second Container contains DropDownList2,TextBox2. I added this usercontrol to the webform and the control name is ctl Now in javascript I want to set the TextBox2 value as the DropDownList1.Selectedvalue and TextBox1 value as the DropDownList2.Selectedvalue. Now i am using this code in JavaScript, this.form['_ctl0:DropDownList1:Text'].value = this.form['_ctl0:DropDownList2:Text'].options[this.selectedIndex].value; but if I place the same user control twice in the webform it wont work, so i want generic code to set the textbox values.
-
Hi I created an UserControl, it contains two container controls. First container contains DropDownList1,TextBox1 and second Container contains DropDownList2,TextBox2. I added this usercontrol to the webform and the control name is ctl Now in javascript I want to set the TextBox2 value as the DropDownList1.Selectedvalue and TextBox1 value as the DropDownList2.Selectedvalue. Now i am using this code in JavaScript, this.form['_ctl0:DropDownList1:Text'].value = this.form['_ctl0:DropDownList2:Text'].options[this.selectedIndex].value; but if I place the same user control twice in the webform it wont work, so i want generic code to set the textbox values.
You generate the javaascript in page cs file instead of hardcoding in the aspx page like this.
string jsStr = "this.form['" + yourControlVar.UniqueId + "']. value..."
-
You generate the javaascript in page cs file instead of hardcoding in the aspx page like this.
string jsStr = "this.form['" + yourControlVar.UniqueId + "']. value..."
Hi, In my user control, I have two DropDownList boxes(two instances of DropDownList user control) and this DropDownList box itself an usercontrol. It is not possible to set from the .cs file. I want to set it from JavaScript only. Reagrds, Chakravarthy.v
-
Hi, In my user control, I have two DropDownList boxes(two instances of DropDownList user control) and this DropDownList box itself an usercontrol. It is not possible to set from the .cs file. I want to set it from JavaScript only. Reagrds, Chakravarthy.v
I created User Controls WebUserControl1 which contains a button. Another UserControl WebUserControl2 which contains the WebUserControl1. I am using the WebUserControl2 instance in a page. I added javascript code for click event of the Button in the page hosting the WebUserControl2. It is working perfectly.
protected override void OnPreRender(EventArgs e) { base.OnPreRender (e); Button btn = (Button) this.WebUserControl21 .FindControl("WebUserControl11").FindControl("Button1"); string jsStr = "alert('" + btn.UniqueID + "');return false;"; btn.Attributes.Add("onclick", jsStr); }