Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have user control page as follows
C#
 protected void Page_Load(object sender, EventArgs e)
{
    if (Session["CurrentUser"] == null)
    {
        Response.Redirect("Login.aspx");
    }
    if (!IsPostBack)
    {
        try
        {
            this.LstMinorCode.Visible = false;
            this.LstCrsDate.Visible = false;
            SQl = "select cmj_major_code,cmj_major_desc from co_major_master where cmj_active <> 'D'";
            Dr = SCon.ReadSql(SQl);
            this.DdlMajoreCode.DataSource = Dr;
            this.DdlMajoreCode.DataTextField = "cmj_major_desc";
            this.DdlMajoreCode.DataValueField = "cmj_major_code";
            this.DdlMajoreCode.DataBind();

            Dr.Close();
        }
        catch (Exception e1)
        {
            this.Label1.Text = e1.Message.ToString();
        }
    }
}

      I HAVE ANOTHER PAGE CONFIRMATION.ASPX as Follows

      protected void Page_Load(object sender, EventArgs e)
     {
        if (Session["CurrentUser"] == null)
            Response.Redirect("login.aspx");

       if (!IsPostBack)
         {
             Gettype();
         }
     }

     private void Gettype()
    {
   Sql = "select DISTINCT Type FROM Admin_Track";
   Dr = SCon.ReadSql(Sql);
   ddlType.Items.Clear();
   ddlType.DataTextField = "Type";
   ddlType.DataValueField = "Type";
   ddlType.DataSource = Dr;
   ddlType.DataBind();
   Dr.Close();
  }

   protected void btn_show_Click(object sender, EventArgs e)
   {

   }

in the user control page, in the page load i want to set visible the button true. This button in the CONFIRMATION page.

for that how can i do in asp.net using c#
Posted
Updated 31-Aug-15 20:47pm
v2
Comments
F-ES Sitecore 1-Sep-15 4:16am    
What's the relation between the code you have pasted and the confirmation page?

1 solution

There are a couple of ways to do this, but if you want to do it in page_load then you will have to expose the property of the button to the page:


MyControl.ascx.cs
C#
public partial class MyControl: UserControl
{
   public bool MyButtonVisibility
   {
      set{ MyButton.Visible = value; }

   }
}

MyPage.aspx.cs
C#
public partial class MyPage: Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      if(condition)
        MyControl1.MyButtonVisibility = false;
   }
}



Hope that helps ^_^
Andy
 
Share this answer
 

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