I have one master page that is used to gather information from a user. It contains asp.net labels and textboxes within a table. For example, the master page contains fields for Name , Phone, Address, etc.
There are content pages that are created to add to the information that needs to be gathered. For example, the content page, Loan Application, could ask for Loan Amount, LTV, etc.
In addition to this, certain content page forms do not need to show a particular master page field. For example, the content page may not need to ask for Phone.
The table rows are stored as public properties in the master page so I can hide them in the content page code behind.
public bool HomePhoneRow
{
set { trHomePhone.Visible = value; }
get { return trHomePhone.Visible; }
}
So, in the content page code behind, I have this:
Master.HomePhoneRow = false;
The functionality works perfect, but I don't like how the space is reserved on the page. You can tell that a row was removed. I've tried style="border-collapse:collapse" on both the <table> and <tr> elements. I've also tried to set the row height as a
public property and alter that. I'm stumped. There must be a way?
Thank you. I certainly learned something new here. I appreciate your time.
The value ? is new to me, though. What is the translation of this syntax? I know it is basically stating that displaying the table-row is true and not displaying is false, but what is the "?" for?
I did know you could code the property this way, but I need this as a public bool property in the master page. The other solution posted by Caspar is good, though.
Member
1 Points
5 Posts
Hide master page html table row from content page
Jan 28, 2010 09:54 AM|TChau|LINK
I have one master page that is used to gather information from a user. It contains asp.net labels and textboxes within a table. For example, the master page contains fields for Name , Phone, Address, etc.
There are content pages that are created to add to the information that needs to be gathered. For example, the content page, Loan Application, could ask for Loan Amount, LTV, etc.
In addition to this, certain content page forms do not need to show a particular master page field. For example, the content page may not need to ask for Phone.
The table rows are stored as public properties in the master page so I can hide them in the content page code behind.
public bool HomePhoneRow
{
set { trHomePhone.Visible = value; }
get { return trHomePhone.Visible; }
}
So, in the content page code behind, I have this:
Master.HomePhoneRow = false;
The functionality works perfect, but I don't like how the space is reserved on the page. You can tell that a row was removed. I've tried style="border-collapse:collapse" on both the <table> and <tr> elements. I've also tried to set the row height as a public property and alter that. I'm stumped. There must be a way?
master page content page Code behind hide row
Participant
1772 Points
442 Posts
Re: Hide master page html table row from content page
Jan 28, 2010 11:11 AM|Caspar Kleijne|LINK
perhaps this works:
Caspar Kleijne,
the Netherlands
Participant
943 Points
251 Posts
Re: Hide master page html table row from content page
Jan 28, 2010 11:16 AM|Bhavin Shah|LINK
In place of visible property try to use display style.
trHomePhone.Style.Add("display", "block");
trHomePhone.Style.Add("display", "none");
hope this helps........
http://www.linkedin.com/in/bhavinjshah
Member
1 Points
5 Posts
Re: Hide master page html table row from content page
Jan 28, 2010 03:32 PM|TChau|LINK
Thank you. I certainly learned something new here. I appreciate your time.
The value ? is new to me, though. What is the translation of this syntax? I know it is basically stating that displaying the table-row is true and not displaying is false, but what is the "?" for?
Member
1 Points
5 Posts
Re: Hide master page html table row from content page
Jan 28, 2010 03:34 PM|TChau|LINK
Bhavin -
I did know you could code the property this way, but I need this as a public bool property in the master page. The other solution posted by Caspar is good, though.
Thanks!
Participant
1772 Points
442 Posts
Re: Hide master page html table row from content page
Jan 28, 2010 03:40 PM|Caspar Kleijne|LINK
the ? : syntax is just a shorthand for if else it is less readible but shorter to write down. ( http://msdn.microsoft.com/en-us/library/ty67wk28(VS.80).aspx )
instead of
you could write
Caspar Kleijne,
the Netherlands
Member
1 Points
5 Posts
Re: Hide master page html table row from content page
Jan 28, 2010 04:30 PM|TChau|LINK
Great explaination! Thanks again!