Web Forms :: Provide SiteMapDataSource From Code Behind C#
Jan 19, 2010
in my masterpage I have the following:
<asp:SiteMapDataSource
ID="MenuSiteMap"
runat="server"
ShowStartingNode="False"
SiteMapProvider="SpanishSiteMap"
/>
In My code behind I want to provide the SiteMapProvider instead of having it hard coded from the aspx page. What would the code look like to replace in thie case 'SpanishSiteMap' and have that come from code behind in c#? I thought something like this but i know this is way off. hopefully someone has a one liner code that will give provide some sleep. I've come closer to a working code. this is what i have... but get the error mentioned below.
MasterPage myMasterPage = (MasterPage) this.Master;
// do a find control on myMasterPage and find the siteMapDataSource
SiteMapDataSource mySiteMapDataSource = (SiteMapDataSource)myMasterPage.FindControl("MenuSiteMap");
// now u have the reference to the siteMapDataSource used in the master page how do I set the provider..
mySiteMapDataSource.Provider = "SpanishSiteMap";
Error: Cannot implicitly convert type 'string' to 'System.Web.SiteMapProvider'
View 2 Replies
Similar Messages:
Jul 2, 2010
In asp.net web application I have restricted users actions depending on their roles like as follow
I have created three tables in database
Tables
Table: Users
UserID Username Password
1 Bob password1
2 Scott password2
3 Jisun password3
4 Sam password4
5 John password5
Table:Groups
GroupID Name
1 Administrators
2 Clerk
3 Manager
4 Cashier
Table:Roles
UserID GroupID
1 1
2 2
2 3
3 4
4 3
4 4
In Global.asax file I have written the following
Sub Application_AuthenticateRequest(sender As Object, e As EventArgs)
If Request.IsAuthenticated Then
'Determine this user's roles[code].....
as of now it is working fine. Now a new requirement has araised that to allow the clerk to access some of (but not all) functionalities perfomred by administrator.
Do i need to change my source code to provide above new requirement?
Do I need to do the same again and again when such requirement araises in future ?
View 6 Replies
Feb 17, 2010
When I declare the TreeView Nodes:
[Code]....
I can programmatically control the collapse and expansion of nodes:
[Code]....
When I use a SiteMapDataSource:
[Code]....
How do I now programmatically expand and collapse nodes? The code above doesn't work because the number of nodes is now 0.
View 1 Replies
Aug 5, 2010
I have been looking for a answer but could not find one that I could understand (I am not a pro, far from this...). I have a menu and a sitemapdatasoure, working fine by now. I would like to show the menu options based on the role of each user. I know it can be done with SQL Server, but I don't have it, I use MySQL.
View 2 Replies
Jan 30, 2010
how can i get site map data from the SiteMapDataSource in codebehind same as i would if i wanted to create a typical dataSet from an XML File?
i want to create a custom menu programmaticaly and already wrote out a site map - i know i can just copy it to an xml file but I want to know if its possible to access it from a SiteMapDataSource like
SiteMapDataSource ds = new SiteMapDataSource();
//iterate through nodes to create custom controls, etc...
View 3 Replies
Sep 7, 2010
I'm following a tutorial from [URL] to create a better menu with submenus. Does anyone know how to convert this inline code to code behind? I'm not a big fan of inline code but I have no idea on how to convert it to code behind.
[Code]....
View 1 Replies
Nov 12, 2010
somewhere on the net I found very useful example of programatically databainding the treeview control (code blow). I use this treeview as menu bar in my masterpage. It works fine but with one exception: when I click the node of this treeview I'm redirected to the correct page but after page is reloaded my treeview is collapsed and node I chose just before is not highlighted. What to do to correct this problem. Do you know better examples of programatically databainding of the treeview control? Maybe it will be better to bind data to the sitemapdatasource and next to the treeview. Then I shouldn't have to worried about this?
[Code]....
Regards. Pawel
View 1 Replies
Feb 10, 2010
Sample SiteMap snippet:
<siteMapNode url="~/Folder/File.aspx" title="Aspx Page">
<siteMapNode url="~/Folder/File.aspx#Toc" title="Introduction & Table of Contents">
</siteMapNode>
<siteMapNode url="~/Folder/File.aspx#Anchor1" title="Section 1">
</siteMapNode>
<siteMapNode url="~/Folder/File.aspx#Anchor2" title="Section 2">
</siteMapNode>
<siteMapNode url="~/Folder/File.aspx#Anchor3" title="Section 3">
</siteMapNode>
<siteMapNode url="~/Folder/File.aspx#Anchor4" title="Section 4">
</siteMapNode>
</siteMapNode>
When the URL is ~/Folder/File.aspx#Anchor1, I want "Section1" to be automatically selected in the TreeView. However, "Aspx Page" is always displayed no matter what the anchor is. Do I have to override SiteMapDataSource, create a new SiteMapProvider, or is there an easier way to do this? When binding a TreeView to a SiteMapDataSource,
View 5 Replies
Jan 18, 2011
I have a Default.aspx program that contains a Treeview with a SiteMapDataSource. I also have a web.sitemap loaded up with urls. When I run the deafult app I get the tree layout that matches the numbers of options but no text on any of the options to click.
View 1 Replies
Jan 19, 2011
I am just starting out with ASP.net and C#.
I have a master page that contains the main site navigation and a child master page that contains a secondary menu. I want to set the starting node on the secondary menu based on the selection on the main menu.
I can get the code to work when the menus are on the same page, but when I separate them into their respective master pages, I get an error saying "The name 'SiteMapDataSource2' does not exist in the current context".
I have tried playing around with the FindControl() method, but either it won't work or I'm not getting the syntax right. Most of the information I find is for a child page referencing the master page, but not the other way around.
How can I access the SiteMapDataSource2 control from the master page? If possible, can you include the exact syntax as I am still trying to get the hang of this.
Here is a basic representation of my code, with all of the uncessary stuff stripped out:
Master Page
[Code]....
Master Page Codebehind
[Code]....
Child Page
[Code]....
View 2 Replies
May 7, 2015
How to provide security in wcf in different ways(certificates,tokens and more) including transport level and message level?
View 1 Replies
Nov 25, 2010
in my webpage textbox is there in that text box provide regular expression like Ord1,Ord2,means
first three charcters alphbets,the first alphabet stat with Uppercase letter and fourth numerical value dispalyed,
and remaining no need do display any characters when user enters
View 8 Replies
Jul 30, 2010
Where can i find a good source to accomplish this? It needs to allow only excel or csv file uploads, which would be inserted into the database.
View 12 Replies
Nov 29, 2010
in my webpage checkbox is there, if am not checked checkbox when am submit the button click it will
come alert message or it will give an error msg .
View 8 Replies
Mar 28, 2011
I have bound data to text values of many textboxes using dataset as follows,
[Code]....
Now I want to provide a navigation system such as first, previous, next, last buttons as there are many rows returned from the query. I tried but could not succeed.
View 1 Replies
Mar 9, 2011
i need to provide tooltips for dropdownlist items,
so how to provide tooltips for ddl items,
View 2 Replies
Jun 14, 2010
My application requirement is, there should be different Layout themes (not only colors but also controls can be at different location), which user can easily change. How I can do that?
For eg. In wordPress there are different layout themes,
How should be the site folder structure? How I can implement that?
View 1 Replies
Apr 20, 2010
I've basically got 2 applications. One is my back office application (Admin) and the other , the front end application (web site)
My problem is that, the admin uploads 'n' number of photos ,which is stored in one of the folders within my back office application and the path is stored in my DB as , for example : ~/Uploads/test.jpg.
But it is not possible for me to access this image from my front end application because the path actually exists in my back office app. How do i get to view the images that I uploaded on my front end Appn. ?
View 2 Replies
Oct 11, 2012
How to provide an alternate image when the original image is missingĀ ....
View 1 Replies
Apr 26, 2010
I am trying to create a list view to provide functionality similiar to the pages in this article(will end up being much simpler in my case)
[URL]
Basically I need three columns. Column 1 will be populated on page load with a list of user names and some data. Clicking on a user from column 1 will query for data regarding that user and bring back multiple rows to be displayed in Column 2. Clicking on data from a row in column 2 will return rows to be displayed in column 3. I am just curious as to how some of you guys would approach this. Ive looked at grouping templates and some articles regarding listviews with multiple rows but. Would it be easier to use 3 seperate listviews? Any ideas or articles to point me in the right direction?
View 2 Replies
Feb 25, 2011
i've got a gridview and sql datasource. Its connected to a stored proc that has four optional parameters. In VS when i set up the data source, if i use the test option, and dont supply any values for the sproc, it returns all the values in the table which is what it should do. Now when i try to fill the gridview, it wont return anything at all unless i provide values for all 4 parameters.
It's not even trying to search because i had sql profiler open and nothing shows up until i provide all 4 values. any idea why it's doing this? How do i get it to actually bind even if provide less then all 4 (or none) of the values?
View 1 Replies
Mar 5, 2010
I have a page with a table and two button with the names (Submit and Add Rows) When I click on Add Row a new row will be added to a page(This is achieved using javascript), when I click on submit button I will be doing server side validation. If I found any error the error will be displayed on the page. During this process the controls which were added by me were loosing its state. As a result I need to add the rows once again and need to fill the data and click on submit button. Can any one let me know how to avoid this and see that the controls donot loose their states. So that there is no need for me to create rows once again if any validation fails on the server side.
View 1 Replies
Oct 11, 2010
Does LabelFor look for a template? Is it possible to provide a template for LabelFor?The issue i have is the "for" attribute of label matches a field "id" attribute. In the case of radio or checkbox lists my id's generally take the form of "propertyname_0", "propertyname_1" etc. Simply referencing "propertyname" in the for attribute is not effective.
View 5 Replies
Apr 16, 2010
i want the logic for rating.
View 1 Replies
Dec 21, 2010
I landed on a job to continue working on exisiting asp.net 3.5 application using Visual Studio 2008. The former .net developer is no longer around and I have to dig into the application code to understand how the app works( workflow, logic, etc...)I have added new development to the existing application and enhanced existing pages. Now, I need to provide Technical documentation for the application so any new developer comes onboard will not struggle enhancing the app or do new development following the same methodology . Q1. What is the best approach to provide technical documentation.I thought of the following
View 1 Replies