Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
defaut.aspx page coding

XML
</head>
<body>
    <form id="form1" runat="server">
    <div>
        welcome: &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Label"></asp:Label><br />
        You visted on: &nbsp;
        <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Label"></asp:Label></div>
        <br />

        <hr width="40%" align="left" />
        <br />
        <br />

        Enter your name: &nbsp;&nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>&nbsp;
        <asp:Button ID="Button1" runat="server" Text="Save"  />
    </form>
</body>
</html>


defaut.aspx.cs coding

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

       

            string hh;
            hh = Request.QueryString["name"].ToString();
            Profile.Name = hh;
            Profile.Save();
            Label1.Text = hh;
       
    protected void Page_UnLoad(object sender, EventArgs e)
    {
        Profile.VisitedOn = DateTime.Now;
        Profile.Save();
    }


gg.aspx 

 page coding from which i will send a name to default page through
query string

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server">
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    
    </div>
    </form>
</body>
</html>
    

gg.aspx.cs

 protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("default.aspx?name=" + TextBox1.Text);
    }
}



now question is that values changed of label in default.aspx page when i go from gg.aspx page to defaut.aspx page but when i open directly default.aspx page 
values of label text retained.
i want that when i enter through default.aspx page values shoud be changed.
plzz anybody
Posted

1 solution

XML
<asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Label">


See the Text="Label" part in bold above? Specify whatever text you want to see here when the page is loaded directly and that should be it.

If the text is dynamic (either coming from database or based on some logic), change it in your Page_Load event of the page.
 
Share this answer
 
Comments
rameshkumar55 9-Nov-12 0:13am    
i want client side change in text of label that should not be retained page redirection
Ankur\m/ 9-Nov-12 0:20am    
Use JavaScript then. Decide the event based on when do you want to change it. If it's page load, use window's onload event. Search Google for how to change label text javascript and you will find how to do it.
hope that helps!

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