views:

62

answers:

2

I have created a custom text box with property "key"(ASP.NET C#).I want to get the value of this property "key" using java script.How can I do this?

+2  A: 

Not sure what you are asking.

if you have a textbox rendered like so:

<input type="text" id="foo" key="somekey" text="Hello" />

You could get the value of "key" in JS like so:

document.getElementById('foo').getAttribute('key')
Raj Kaimal
I have created a server side custom control <cus:TextBox id="foo" Key="somekey" runat="server" Text="Hello"/>I want to get the value of key.In view source Html generated is <input type="text" id="foo" text="Hello" />No Html is generated for custom property Key.
Dee
If key is not generated in the html, then you have a problem with your custom control.
Raj Kaimal
A: 

If you are using jquery than for this will help you.

$("#tb1").attr("key")

for this textbox

<input type="text" id="tb1" key="mykey" text="" />
Sharique