Replace the text of a textbox when the user makes a new input in the same textbox

-1

I have a textbox where, through another page I give you an email.

txtemail.text = "[email protected]"

And when my page does load , in that textbox it appears: [email protected] .

But if I try to make a new input on that textbox it does not save, always with [email protected] .

I have AutoPostBack="true" , I already tried OnTextChanged but I could not.

I needed something of the sort.

txtemail.text = txtemail.text.newInput()

This is my textbox

<div class="form-group">
<asp:Label ID="LEmailP" runat="server" Text="Para :" Font-Size="Medium" Font-Bold="true"></asp:Label>
<asp:TextBox CssClass="labelEmail" ID="txtEmailP" required="true" MaxLength="50" runat="server" type="text" TabIndex="2" AutoPostBack="true" pattern="[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$" title="ex: [email protected]" placeholder="Titular Email"></asp:TextBox>
</div>

I'm passing my email by page here (I put it in page load)

string email = Request.QueryString["email"]; txtEmailP.Text = email;

    
asked by anonymous 27.09.2018 / 16:44

1 answer

1

Well you have not put your code, but given the behavior, you can say that you are assigning the value passed in QueryString to your input txtEmail in the Page_Load() event. And how do you assign the behavior of AutoPostBack="True" to it or any other component on the screen. Whenever this feature is activated you will pass Page_Load() again and you will receive the value you are informed in QueryString .

The solution is simple, add the condition so that this assignment only occurs when the page load does not come from a PostBack

protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    {
        txtEmail.Text = Request.QueryString["email"];
    }

}
    
28.09.2018 / 12:18