Monday, March 26, 2012

newbie: Problems in the code... again

hey

asp.net 2.0

On my webpage have I placed a LoginView (named lvSidebar). On this
loginview's loggedInTemplate I placed a menu (mnuSidebar) and the datasource
to the menu is SiteMapDataSource1.

My Problem is that I cannot access the SiteMapDataSource1 object from the
code:
lvSidebar.LoggedInTemplate.SiteMapDataSource.Start ingNodeUrl =
"Default.aspx";
don't compile:
System.Web.UI.ITemplate' does not contain a definition for
'SiteMapDataSource1'

Any ideas what I should do to solve this?

JeffThe LoggedInTemplate property of the LoginView control does not have a
property called SiteMapDataSource which is what is causing the error. If you
want to prograamatically set the StratingNodeURL property of
SiteMapDataSource1 simply use the following code

SiteMapDataSource1.StartingNodeUrl = "Default.aspx";

The LoginView has nothing to do with it.

"Jeff" wrote:

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
On my webpage have I placed a LoginView (named lvSidebar). On this
loginview's loggedInTemplate I placed a menu (mnuSidebar) and the datasource
to the menu is SiteMapDataSource1.
>
My Problem is that I cannot access the SiteMapDataSource1 object from the
code:
lvSidebar.LoggedInTemplate.SiteMapDataSource.Start ingNodeUrl =
"Default.aspx";
don't compile:
System.Web.UI.ITemplate' does not contain a definition for
'SiteMapDataSource1'
>
Any ideas what I should do to solve this?
>
Jeff
>
>
>


hmm when I in the code start to type "SiteM" the SiteMapDataSource1 isn't
shown in the type-ahead list... this happens if I try to access the
SiteMapDataSource like this SiteMapDataSource1.StartingNodeUrl =
"Default.aspx"; or
lvSidebar.LoggedInTemplate.SiteMapDataSource.Start ingNodeUrl

Another thing is that my webpage has 2 SiteMapDataSource1 controls (yes they
have the same name, but they exist in their own LoginView, lvSidebar and
lvMenu).

Any more suggestions?

Jeff

"clickon" <clickon@.discussions.microsoft.comwrote in message
news:258E83E3-C3EC-4948-93FC-E30DC3F811FD@.microsoft.com...

Quote:

Originally Posted by

The LoggedInTemplate property of the LoginView control does not have a
property called SiteMapDataSource which is what is causing the error. If
you
want to prograamatically set the StratingNodeURL property of
SiteMapDataSource1 simply use the following code
>
SiteMapDataSource1.StartingNodeUrl = "Default.aspx";
>
The LoginView has nothing to do with it.
>
"Jeff" wrote:
>

Quote:

Originally Posted by

>hey
>>
>asp.net 2.0
>>
>On my webpage have I placed a LoginView (named lvSidebar). On this
>loginview's loggedInTemplate I placed a menu (mnuSidebar) and the
>datasource
>to the menu is SiteMapDataSource1.
>>
>My Problem is that I cannot access the SiteMapDataSource1 object from the
>code:
>lvSidebar.LoggedInTemplate.SiteMapDataSource.Start ingNodeUrl =
>"Default.aspx";
>don't compile:
>System.Web.UI.ITemplate' does not contain a definition for
>'SiteMapDataSource1'
>>
>Any ideas what I should do to solve this?
>>
>Jeff
>>
>>
>>


If you want to access a control that is within another control you need to
use the following syntax:

ParentControl.FindControl("ChildControlID")

This will return a reference to the child control. You will also need to
cast it to the correct type.

In your case you would use something like the below C# code

SiteMapDataSource MySiteMapDataSource = (SiteMapDataSource)
lvSidebar.FindControl("SiteMapDataSource1");
MySiteMapDataSource.StartingNodeUrl = "Default.aspx";

"Jeff" wrote:

Quote:

Originally Posted by

hmm when I in the code start to type "SiteM" the SiteMapDataSource1 isn't
shown in the type-ahead list... this happens if I try to access the
SiteMapDataSource like this SiteMapDataSource1.StartingNodeUrl =
"Default.aspx"; or
lvSidebar.LoggedInTemplate.SiteMapDataSource.Start ingNodeUrl
>
Another thing is that my webpage has 2 SiteMapDataSource1 controls (yes they
have the same name, but they exist in their own LoginView, lvSidebar and
lvMenu).
>
Any more suggestions?
>
Jeff
>
>
>
"clickon" <clickon@.discussions.microsoft.comwrote in message
news:258E83E3-C3EC-4948-93FC-E30DC3F811FD@.microsoft.com...

Quote:

Originally Posted by

The LoggedInTemplate property of the LoginView control does not have a
property called SiteMapDataSource which is what is causing the error. If
you
want to prograamatically set the StratingNodeURL property of
SiteMapDataSource1 simply use the following code

SiteMapDataSource1.StartingNodeUrl = "Default.aspx";

The LoginView has nothing to do with it.

"Jeff" wrote:

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
On my webpage have I placed a LoginView (named lvSidebar). On this
loginview's loggedInTemplate I placed a menu (mnuSidebar) and the
datasource
to the menu is SiteMapDataSource1.
>
My Problem is that I cannot access the SiteMapDataSource1 object from the
code:
lvSidebar.LoggedInTemplate.SiteMapDataSource.Start ingNodeUrl =
"Default.aspx";
don't compile:
System.Web.UI.ITemplate' does not contain a definition for
'SiteMapDataSource1'
>
Any ideas what I should do to solve this?
>
Jeff
>
>
>


>
>
>


thanks, it solved my problem

"clickon" <clickon@.discussions.microsoft.comwrote in message
news:97D21DB6-ED33-4E35-9702-0F9FB54C24ED@.microsoft.com...

Quote:

Originally Posted by

If you want to access a control that is within another control you need to
use the following syntax:
>
ParentControl.FindControl("ChildControlID")
>
This will return a reference to the child control. You will also need to
cast it to the correct type.
>
In your case you would use something like the below C# code
>
SiteMapDataSource MySiteMapDataSource = (SiteMapDataSource)
lvSidebar.FindControl("SiteMapDataSource1");
MySiteMapDataSource.StartingNodeUrl = "Default.aspx";
>
>
"Jeff" wrote:
>

Quote:

Originally Posted by

>hmm when I in the code start to type "SiteM" the SiteMapDataSource1 isn't
>shown in the type-ahead list... this happens if I try to access the
>SiteMapDataSource like this SiteMapDataSource1.StartingNodeUrl =
>"Default.aspx"; or
>lvSidebar.LoggedInTemplate.SiteMapDataSource.Start ingNodeUrl
>>
>Another thing is that my webpage has 2 SiteMapDataSource1 controls (yes
>they
>have the same name, but they exist in their own LoginView, lvSidebar and
>lvMenu).
>>
>Any more suggestions?
>>
>Jeff
>>
>>
>>
>"clickon" <clickon@.discussions.microsoft.comwrote in message
>news:258E83E3-C3EC-4948-93FC-E30DC3F811FD@.microsoft.com...

Quote:

Originally Posted by

The LoggedInTemplate property of the LoginView control does not have a
property called SiteMapDataSource which is what is causing the error.
If
you
want to prograamatically set the StratingNodeURL property of
SiteMapDataSource1 simply use the following code
>
SiteMapDataSource1.StartingNodeUrl = "Default.aspx";
>
The LoginView has nothing to do with it.
>
"Jeff" wrote:
>
>hey
>>
>asp.net 2.0
>>
>On my webpage have I placed a LoginView (named lvSidebar). On this
>loginview's loggedInTemplate I placed a menu (mnuSidebar) and the
>datasource
>to the menu is SiteMapDataSource1.
>>
>My Problem is that I cannot access the SiteMapDataSource1 object from
>the
>code:
>lvSidebar.LoggedInTemplate.SiteMapDataSource.Start ingNodeUrl =
>"Default.aspx";
>don't compile:
>System.Web.UI.ITemplate' does not contain a definition for
>'SiteMapDataSource1'
>>
>Any ideas what I should do to solve this?
>>
>Jeff
>>
>>
>>


>>
>>
>>

0 comments:

Post a Comment