Javascript Problem in asp.net in Content page
-
I am trying to set value in Label and Dropdown list in Asp.net content page from external javascript file. I did for textbox by passing ClientID of TextBox through parameter as: function setValueInTextBox(ctrVal) { ctrVal.value="strvalue"; } and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")"); This works for TextBox. But i unabled to set values in Label and Dropdownlist controls. What should i do, please suggest me.
-
I am trying to set value in Label and Dropdown list in Asp.net content page from external javascript file. I did for textbox by passing ClientID of TextBox through parameter as: function setValueInTextBox(ctrVal) { ctrVal.value="strvalue"; } and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")"); This works for TextBox. But i unabled to set values in Label and Dropdownlist controls. What should i do, please suggest me.
In javascript to set the value of a label instead of using value property use innerText. Like
ctrl.innerText ='Something';
In case of dropdown list you need to iterate the collection and compare each value in the option collection.
for(var i=0;i
WWW, WCF, WWF, WPF, WFC .... WTF -
I am trying to set value in Label and Dropdown list in Asp.net content page from external javascript file. I did for textbox by passing ClientID of TextBox through parameter as: function setValueInTextBox(ctrVal) { ctrVal.value="strvalue"; } and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")"); This works for TextBox. But i unabled to set values in Label and Dropdownlist controls. What should i do, please suggest me.
-
I am trying to set value in Label and Dropdown list in Asp.net content page from external javascript file. I did for textbox by passing ClientID of TextBox through parameter as: function setValueInTextBox(ctrVal) { ctrVal.value="strvalue"; } and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")"); This works for TextBox. But i unabled to set values in Label and Dropdownlist controls. What should i do, please suggest me.
sharad Pyakurel wrote:
and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")");
Change this to,
btnSet.Attributed.Add("onClick","setValueInTextBox(document.getElementById('"+txtValue.ClientID+"'))");
Castle Rider
What if I freeze??? Don't forget to breath...
My: Website | Yahoo Group | Blog Spot
-
sharad Pyakurel wrote:
and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")");
Change this to,
btnSet.Attributed.Add("onClick","setValueInTextBox(document.getElementById('"+txtValue.ClientID+"'))");
Castle Rider
What if I freeze??? Don't forget to breath...
My: Website | Yahoo Group | Blog Spot
Thankyou Castle Rider. It worked. btnSet.Attributed.Add("onClick","setValueInTextBox(document.getElementById('"+txtValue.ClientID+"'))");
-
Thankyou Castle Rider. It worked. btnSet.Attributed.Add("onClick","setValueInTextBox(document.getElementById('"+txtValue.ClientID+"'))");
You are welcome. You can mark it as Answer if it helped you... :-D
Castle Rider
What if I freeze??? Don't forget to breath...
My: Website | Yahoo Group | Blog Spot