zoukankan      html  css  js  c++  java
  • 关于textbox.attributes["value"]的问题

    在“修改”时,出现这个问题,后台点击修改时,应该是文本框出现一些初始值

    BLL.manager bll = new BLL.manager();
    Model.manager model = bll.GetModel(_id);
    ddlRoleId.SelectedValue = model.role_id.ToString();
    rblIsLock.SelectedValue = model.is_lock.ToString();
    txtUserName.Text = model.user_name;
    txtUserName.ReadOnly = true;
    if (!string.IsNullOrEmpty(model.user_pwd))
    {
    txtUserPwd.Attributes["value"] = txtUserPwd1.Attributes["value"] = defaultpassword;
    //txtUserPwd.Attributes["text"] = txtUserPwd1.Attributes["text"] = defaultpassword;
    }

    发现,txtUserPwd.Attributes["text"]反倒是在文本框中获取不到密码,也就是文本框为空,而txtUserPwd.Attributes["value"]反倒是可以,而textbox中不是没有value这个属性么??,这里不太懂,转了一个别人类似的问题

    TextBox控件TextMode="Password"時,觸發服務器端事件后,會清空掉TextBox的顯示值

    這幾天遇到一個問題:

    TextBox控件TextMode="Password"時,觸發服務器端事件后,會清空掉TextBox的顯示值。

    在網上找了好久,也沒找到解決的方法。

    所以只得自己找方法解決了,觸發一個服務器端事件后,偵查進去發現TextBox的Text值并不為空,同時在網上發現TextBox1.Attributes["value"]="123456789";可以為TextBox賦值。

    所以我就在TextBox的OnTextChanged事件中讓它執行:

    this.TextBox1.Attributes["value"] = this.TextBox1.Text;

    this.TextBox1.Attributes["value"] = Request.Form[TextBox1.ClientID];

    結果ok。

    但是想試在腳本中,我為TextBox1的value賦值,但是觸發服務器端事件后,還是會清空。實在沒有辦法,暫時也只能這樣處理了。

    如果有朋友有更好的方法解決的話,可以告訴我一下。在這里先謝謝了!

    為了穩妥起見,onpaste="return false" oncut="return false"讓TextBox不可以粘貼、復制。

  • 相关阅读:
    正则式记录
    限制键盘只能按数字键、小键盘数字键、退格键
    windows服务安装记录
    CheckBox使用记录
    you need to be root to perform this command
    Code First 更新数据库 记录
    EF查询记录
    sqlserver数据库存储汉字出现?
    【转】THE ROAD TO SUCCESS--听ERIC XING讲课记录
    Nice Computer Vision package collections
  • 原文地址:https://www.cnblogs.com/wanshutao/p/3815358.html
Copyright © 2011-2022 走看看