0
protected void currency_txt_TextChanged(object sender, EventArgs e)
    {
        amountSymbol.Text = currency_txt.Text;
    }

I'm trying to change a label according to a TextBox, without a button that has to be pressed?

3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by jellybeannn
0

Set True value to AutoPostback property of TextBox1. TextChanged event will be raised when a control leaves the focus.

0
protected void currency_txt_TextChanged(object sender, EventArgs e)
    {
        amountSymbol.Text = currency_txt.Text;
    }

I'm trying to change a label according to a TextBox, without a button that has to be pressed?

you can use onkeypress event of javascript
Like
<asp:Textbox onkeypress="WriteName(this.id);" id="txtT" runat="server">
<asp:Textbox id="txtTest" runat="server">

function WriteName(id)
{
document.getElementById('<% = txtTest.ClientID %>').value=document.getElementById('<% = txtT.ClientID %>').value;
}

textchanged event when occur when you write text after you focus next control that time occur if no text changed that event not fire on server side. you can use this java script

i think this help.

0

Hi chiragsathit,

The code works exactly as I want it. I tested your code on a sepearte page and it works. On my page it does not do anything.

<script type="text/javascript">
function WriteName(id)
{
    document.getElementById('<% = amountSymbol.ClientID %>').value = 
    document.getElementById('<% = currency_txt.ClientID %>').value;
}
</script>

<table>
<tr>
            <td>Currency (eg R, US$, etc)</td>
            <td><asp:TextBox onkeypress="WriteName(id);" ID="currency_txt" runat="server" Width="275px" Text="R"/></td>
            <td>
            </td>
        </tr>
        
        <tr>
            <td><asp:TextBox ID="amountSymbol" runat="server" /></td>
        </tr>
<table>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.