Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to change the name of button1 through text box. here is the aspx code.
ASP.NET
<form id="form1"  runat="server">
    <div>
    <p id="our mission">
        <asp:Button ID="Button1" runat="server" Text="Button" />
        
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
        
    </p>
        <p>
            <asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>
            <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" Visible="False" />
        
    </p>
    </div>
    </form>


here is the code behind.
C#
protected void LinkButton1_Click(object sender, EventArgs e)
  {
      TextBox1.Visible = true;
      Button2.Visible = true;
  }
  protected void Button2_Click(object sender, EventArgs e)
  {

          Button1.Text = TextBox1.Text;


          Button1.ID = TextBox1.Text;
          Button2.Visible = false;
          TextBox1.Visible = false;

it changes the button text for the time being but not permanently. kindly tell me how to change it permanently.
Thanks
Posted
Updated 2-Mar-13 18:48pm
v2

1 solution

You need to persist the data somewhere. You could use a text file on the server and on page_load you read the file and place the contents as the .Text of the button. And save new context to the file as needed. StreamWriter/StreamReader will do the job with the Server.MapPath()[^] method.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900