How to get javascript 'value' property for custom textbox control in asp.net?

What you are doing is you are trying to get a value of MyTextBox1 which is not a textbox in fact, so it does not have a value.

What you are doing is you are trying to get a value of MyTextBox1 which is not a textbox in fact, so it does not have a value. What to do instead: Version 1 - change your script to be like this: and this is quite enough to have a text in javascript. Version 2 - add a property to your TextBox class like this: public TextBox ObjTextBox { get { return objTextBox; } } then change your script like this: this should also work.

I hope this helps!

– Tengiz Apr 7 at 12:19 Thanks for your reply. I want to simulate the same behaviuor of normal TextBox to my control-user.My control-user should not think that this is a composite control. Two approches you suggested will work fine.

However I have to write like document. GetElementById(''); When a compiste control renders, our child controls will be wrapped by SPAN element by-default. Is there any way when text entered in MyTextBox1 has to assign this text to 'value' attribute of wrapped SPAN element.('value' attribute added by writer.

AddAttribute() in Render method – aspnet Developer Apr 7 at 12:40 No, that is incorrect to have value attribute for span. I know that works for some browsers (like IE), but it does not for others (like Mozilla). I guess in that case you will need to create your own textbox not as a composite, but instead as a full-fledged textbox control from scratch.

In general, value attribute has sense only for input controls, like textbox, button, textarea... – Tengiz Apr 7 at 12:49 Thank you for reply. I used the version 2 what you have suggested. Its working well in normal asp.

Net page. But if I put 'MytextBox' and 'button' in a updatePanel, javascript function is working first time if I click the button. I.

E var objTextBox = document. GetElementById(''); alert(objTextBox. Value); --- is giving the whatever I entered in the MyTextBox.

If I click second time button its throwing javascript exception "Microsoft JScript runtime error: Object required" (this error is comming at the line -- alert(objTextBox. Value);). Any idea?

– aspnet Developer Apr 8 at 13:08 This should be related somehow to the updatePanel. What does happen with update panel when you click the button? – Tengiz Apr 8 at 13:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions