remain TextBox value after the page refreshed

前端 未结 1 1843
醉话见心
醉话见心 2021-01-23 12:24

I have a textbox and this is how I assigned value into it

var start = moment().subtract(6, \'days\');
var end = moment();

        $(\'#datePicker\').daterangepi         


        
1条回答
  •  轮回少年
    2021-01-23 12:38

    if this line cb(start,end); overwrite your text box on post back, then do that.

    Add on aspx page one literal to render the variable isPostBack as javascript.

    
    

    Then on code behind render it.

    txtExtraScriptVariables.Text 
        = string.Format("var isPostBack = {0};", IsPostBack.ToString().ToLower());
    

    and now on your script use it as

    if(!isPostBack)
        cb(start,end);
    

    0 讨论(0)
提交回复
热议问题