Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.NET Navigation and Validation quesitons

Posted on 2012-03-31
1
Medium Priority
?
184 Views
Last Modified: 2012-04-03
Two things I am trying to figure out.

Question 1.
A site map comes from the master page.  The site map is displayed in a tree view.  How can I disable the tree view until there are no more pages errors.

Question 2.
Both the current and prior page use  MasterPageFile="~/Site.Master"
And
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"

Page 1 has a control named TextBox1.

Why does this PageLoad() code never find control TextBox1?
{
   ContentPlaceHolder cp = ((ContentPlaceHolder)PreviousPage.Master.FindControl("ContentPlaceHolder1"));
           string fname = ((TextBox)cp.FindControl("TextBox1")).Text;
           valuesFromPriorPage.Text = fname;
}


Thanks
0
Comment
Question by:wilfordrocks
1 Comment
 
LVL 11

Accepted Solution

by:
madgino earned 2000 total points
ID: 37795457
Q1: It's not clear what are you trying to achieve, but I'll try a response:
 - change in code visible =false for tree and change it back when the page is free of errors or
- add  Page_Error event in page and hide the tree if there is any error
http://msdn.microsoft.com/en-us/library/ed577840.aspx
- use try/catch for the code that raises error and manage tree visibility in catch code

Q2: You are probably searching the wrong container:
- try to find control recursive
http://sharpertutorials.com/recursive-findcontrol/
- check if indeed you need to search PreviousPage or directly the Master of the current page:
 ContentPlaceHolder cp = ((ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"));
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question