سؤال

I am using an ASP TextBox and a Telerik RadTextBox in my asp.net webform. I know the The both the controls clear its value after each postback and this is by design due to security reasons.

In my scenario both the controls are ajaxified. Still the ASP TextBox and RadTextBox loses it value on ajax request (partial postback).

So my doubt, is this expected? Will the textbox lose value on both full postback as well as on ajax request?

هل كانت مفيدة؟

المحلول

Both ASP.NET Textbox and Telerik Textbox will be rendered as <input type="password" />. <input type="password" /> is treated a little bit different than the other controls as it contains sensitive information. On every postback they are forcefully cleared.

But if there is some requirement then you can store the information and set it back.

string Password = txtPassword.Text;
txtPassword.Attributes.Add("value", Password);

Note: But I really don't recommend it.

نصائح أخرى

Ajax based function calling never causes Data loss or refresh happened in client side. I think it may be happened due to object you have selected for ajax calling. For eg:

<input type="button" id="Submit">
<input type="submit" id="Submit">

They exhibit different behavior in ajax calling.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top