能不能在JavaScript脚本里实现,因为不想页面被刷新。请问一下怎么实现?

解决方案 »

  1.   

    可以啊。<input type="text" onblur="onvalue();" id="aaa" runat="server" />
    <script>
    function onvalue()
    {
       document.getElementById("Label1").value="修改后的值";
    }
    </script>
      

  2.   

    在textbox的onblur="onvalue();" 事件中执行下面js代码:
    <script> 
    function onvalue() 

      document.getElementById("<%=Label1.ClientID%>").value="修改后的值"; 

    </script> 
      

  3.   

    js代码:function changeText()
        {
            document.getElementById("Label1").innerHTML=document.getElementById("<%=TextBox1.ClientID %>").value;
        }HTML代码:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:Label ID="Label1" runat="server"
                Text="Label"></asp:Label>后台代码:protected void Page_Load(object sender, EventArgs e)
        {
    TextBox1.Attributes.Add("onblur", "changeText();");
    }
      

  4.   

    我的意思是在<asp:Textbox ...../> 实现,不是input里面,而且好像textbox 没有onblur事件,只能在
    <script> 
    function onvalue() 

      document.getElementById("<%=Lable1 %>").value="修改后的值"; 

    </script>
    cs代码
    protected void Page_Load(object sender, EventArgs e)
        {
            Textbox.Attributes.Add("onblar", "onvalue()");
        }
    这样也不能实现
      

  5.   

    可以啊。 
    <input type="text" onblur="onvalue();" id="aaa" runat="server" /> <script> 
    function onvalue() 

      document.getElementById("Label1").innerHTML="修改后的值"; 

    </script> 
      

  6.   

    <asp:TextBox ID ="txt" runat =server Text ="" onblur="hanshu()"></asp:TextBox>
    <script language="javascript">
    var Lbl= '<%=Label.ClientID %>'
    function hanshu()
    {
    Lblobj = document.getElementById(Lbl)
    Lblobj.value = "你想改变的值"
    }
    </script>
      

  7.   

    不好意思,请看一下我的条件,我指的事<asp:Textbox.....>
      

  8.   

    onblur 方法可以再前台设置,也可以再后台设置。
    HTML代码: <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox> 
            <asp:Label ID="Label1" runat="server" 
                Text="Label" onblur="changeText();"> </asp:Label> 也行
      

  9.   

    我刚刚测试了可以啊。你是document.getElementById("Label1").innerHTML
    这里要用innerHTML  用value不行,因为label在浏览器中解析为span,没有value
      

  10.   

    OK 脚本:
    <script language=javascript>
            function setvalue()
           {      
             document.getElementById("<%=LabelUser.ClientID%>").value("Text")="";
           }
    </script>asp页面:
    <asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"></asp:TextBox>
    <asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" ></asp:Label>
    后台:
        protected void Page_Load(object sender, EventArgs e)
        {
            UserNametxt.Attributes.Add("onblar", "setvalue()");
        }
      

  11.   


    <asp:TextBox ID="TextBox1"  runat="server"></asp:TextBox>
    <script> 
    function onvalue() 

      document.getElementById("Label1").innerHTML="修改后的值"; 

    </script>  
     if (!Page.IsPostBack)
            {
                this.TextBox1.Attributes.Add("onblur", "getall()");
            }
      

  12.   

    前台
    <asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"> </asp:TextBox> 
    <asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" > </asp:Label> 
    脚本
    <script language="javascript"> 
            function setvalue() 
          {      
           
            document.getElementById('<%=LabelUser.ClientID%>').innerHTML="aaaaaaaaa"; 
          } 
    </script> 
    后台
    if (!Page.IsPostBack)
            {
                UserNametxt.Attributes.Add("onblur", "setvalue();"); 
     }
    //楼主请及时结贴。可以了。
      

  13.   

    前台
    <asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"> </asp:TextBox> 
    <asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" > </asp:Label> 
    脚本
    <script language="javascript"> 
            function setvalue() 
          {      
           
            document.getElementById('<%=LabelUser.ClientID%>').innerHTML="aaaaaaaaa"; 
          } 
    </script> 
    后台
    if (!Page.IsPostBack)
            {
                UserNametxt.Attributes.Add("onblur", "setvalue();"); 
     }
    //楼主请及时结贴。可以了。
      

  14.   

    document.getElementById(' <%=LabelUser.ClientID%>').innerHTML
    这样是正确的