Click here to Skip to main content
11,429,777 members (73,485 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET4.0
defaut.aspx page coding

</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

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 8-Nov-12 6:58am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

<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.
  Permalink  
Comments
rameshkumar55 at 9-Nov-12 0:13am
   
i want client side change in text of label that should not be retained page redirection
Ankur\m/ at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.150428.2 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100