Click here to Skip to main content
12,065,756 members (31,953 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET .NET
first page
html code:
<asp:Button ID="btn_view" runat="server" Text="View" onclick="btn_view_Click" />
<asp:Button ID="btn_view" runat="server" Text="update" onclick="btn_update_Click" />
c# code:
   protected void btn_view_Click(object sender, EventArgs e)
   {
        string str = "";
       Session["btn_view"] = str;
       Response.Redirect("secondpage.aspx");
   }
protected void btn_update_Click(object sender, EventArgs e)
   {
       Session["update"]=str_d ;
       Response.Redirect("secondpage.aspx");
   }
second page:
html code:
<asp:Button ID="btn_Delete" runat="server" Text="Delete" 
                                onclick="btn_Delete_Click" />
         
                        <td id="cell_update"  runat="server" class="textbox_align" >
                             
                            <asp:Button ID="btn_Update" runat="server" Text="Update" 
                                onclick="btn_Update_Click" />
c# code:
    protected void Page_Load(object sender, EventArgs e)
    {
        cell_view.InnerText = Convert.ToString(Session["btn_view"]);
 if (StrView == "")
        {
            btn_Update.Visible = false;
            btn_Delete.Visible = true;
 
        }
        else
        {
            btn_Update.Visible = true;
}
plz modified this code
Posted 17-Apr-13 8:53am
Edited 17-Apr-13 20:38pm
v7
Comments
ThePhantomUpvoter 17-Apr-13 14:05pm
   
A solution to what? This is just a code dump. No question asked or description of a problem given.
Sergey Alexandrovich Kryukov 17-Apr-13 14:31pm
   
ASP.NET? Please add a tag "ASP.NET".
—SA
@AmitGajjar 18-Apr-13 1:31am
   
You can use session variable to store your visibility flag for your next page control.
Rohan Leuva 18-Apr-13 1:39am
   
then whats the question,whats the error,whats the problem? Frame the question properly so that somebody can respond to you.
TusharKhairnar 18-Apr-13 2:03am
   
Use Query string in first page and check in second page if query string having value then disabled the controls.

1 solution

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

Solution 1

Hi,

you can make use of query string. try like below.

First Page.
protected void btn_view_Click(object sender, EventArgs e)
{
    string str = "";
    Session["btn_view"] = str;
    Response.Redirect("secondpage.aspx?Type=view");       
}
protected void btn_update_Click(object sender, EventArgs e)
{  
    Session["update"]=str_d ;
    Response.Redirect("secondpage.aspx?Type=upd");
}

Second Page.
protected void Page_Load(object sender, EventArgs e)
{
    if(Request.QueryString["Type"].ToString() == "view")
    {
        btn_Update.Visible = false;
        btn_Delete.Visible = true;
    }
    else if(Request.QueryString["Type"].ToString() == "upd")
    {
        btn_Update.Visible = true;
    }    
}

refer Passing variables between pages using QueryString[^] for more on query string.

hope it helps.
  Permalink  
Comments
Member 9959371 18-Apr-13 1:56am
   
thanks for solve my problem
Karthik Harve 18-Apr-13 2:02am
   
welcome. !!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160207.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2016
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