2

I have some dynamic controls in my asp.net page.

like,

TextBox ratingtxtbox = new TextBox();
ratingtxtbox.ID = "Rating_1";

and

DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();

For my textbox I'm added keyup event as

ratingtxtbox.Attributes.Add("onkeyup", "ChangebyWin(" + i.ToString()+")");

Its perfectly working..

Now I added indexchanged event of dropdown list as

Exsecondpositiontxtbox.Attributes.Add("onselectedindexchanged", "ChangebyExacta(" + i.ToString() + ")");

But it not working.. Is it the error in Key name..?

2
  • You really need to share your javascript code as well. Also are you using ClientIDMode=Static on those controls? As that won't actually be the ID unless you are. Commented Jan 24, 2013 at 11:21
  • 1
    please try onchange instead of onselectedindexchanged. Commented Jan 24, 2013 at 11:21

2 Answers 2

2

You should use onchange instead. OnSelectedIndexChanged is a server-side event

Exsecondpositiontxtbox.Attributes.Add("onchange", "ChangebyExacta(" + i.ToString() + ")");

Here is how you would use OnSelectedIndexChanged

Exsecondpositiontxtbox.SelectedIndexChanged += SomeEventHandler;
Sign up to request clarification or add additional context in comments.

Comments

0

try this

Exsecondpositiontxtbox.Attributes.Add("onchange", "ChangebyExacta(" + i.ToString() + ")");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.