user8002547
user8002547

Reputation:

How to get a disabled div value on C# code behnd?

On my C# asp.net web application I disabled a div inputs using jquery

$(document).ready(function () {
     $('[id*=Dis1] :input').attr('disabled', true);
});

Design

<div class="col-sm-3" id="Dis1">
  <asp:TextBox ID="txtBranch" autocomplete="off" runat="server"></asp:TextBox>
</div>

When i am tring to take the value from C# code behind as

string branch = txtBranch.Text;

variable branch is getting null value.

is it possible to get this value on code behind or am wasting my time ??
should i use use jquery to get this value ??

Upvotes: 0

Views: 186

Answers (1)

programtreasures
programtreasures

Reputation: 4298

Disabled fields are not submitted while you submit the form, you need to make it readonly instead disable

$(document).ready(function () {
     $('[id*=Dis1] :input').prop('readonly', true);
});

and apply disable CSS to the field,

[id*=Dis1] :input {
    background: #dddddd;
}

Or else you need to store it in hidden field, and you will able to access the value

Upvotes: 3

Related Questions