Jump to content

[Resolvido] Colocar valor automático em textBox


killzone3
 Share

Recommended Posts

Ora ve lá o exemplo:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox runat="server" ID="t1"></asp:TextBox>
        <asp:TextBox runat="server" ID="t2"></asp:TextBox>
    </div>
    </form>
</body>
</html>

protected void Page_Load(object sender, EventArgs e)
    {
        t1.Attributes.Add("onblur", "document.getElementById('" + t2.ClientID + "').value = this.value;");
    }
Link to comment
Share on other sites

a eu pos igual a ti mas nao dá olha:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:TextBox ID="T1" runat="server"></asp:TextBox>
        <br />
        <asp:TextBox ID="T2" runat="server"></asp:TextBox>
        <br />
        <br />
       
    </div>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        T1.Attributes.Add("onblur","document.getElementbyId('" +T2.ClientID + "').value=this.value;");
        
    }
   
    
    
}

Eu  clico na texbox t2 e nao aparece o texto da t1

Link to comment
Share on other sites

Boas,

Eu por acaso tambem precisava de algo parecido mas a chamar uma funçao por exemplo:

 

protected void btn_Gateway_click1(object sender, EventArgs e)
    {
        txt_gateway.Text = IpBitsToString(IpStringToIpBits(txt_gamaIp.Text)+1);
    }

como implemento essa função nessa forma?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.