SujeshChandr
SujeshChandr

Reputation: 21

asp.net C# -Serverside controls

I want to clear the server side control textbox which is readonly set to true.

I used the jquery $('#mycontrol').val('');

textbox is cleared using this code.But the val property of textbox still have value,which appears in the textbox during postback,since AutoPostBack = true for this control.

Upvotes: 0

Views: 137

Answers (2)

Md Nazmoon Noor
Md Nazmoon Noor

Reputation: 3317

If its a serverside control you can use jquery partial reference of ID

$('[id^="mycontrol"]').val("");

Upvotes: 0

Ben Bartle
Ben Bartle

Reputation: 1080

It may be because the server changes the control id when it renders it. You can access this id with

$('#<%=mycontrol.ClientID%>')

You can also add ClientIDMode=static on the control to prevent this behavior.

Upvotes: 2

Related Questions