how to exclude root node in XML for displaying menu? - asp.net

I want to attach the xml file data to the menu through the XmlDataSource.
I did that but it display from root node. How to do if do not want root node menu. & all the sub menus in same level. eg File, Edit, View etc. Because not to do so then we get unnecessary one extra level for root level menu.
Regards,
Girish

Use the XmlDataSource.XPath property to specify the entry point to the data you want to show for example
XmlDataSource.XPath = "xml/submenus";

Modify the XPath to point to the correct tags in the xml file.
ASPX:
XPATH="ROOT/TARGET"
XML:
<ROOT>
<TARGET TEXT="STARTS HERE">
<DATA TEXT="OTHER DATA HERE" />
</TARGET>
</ROOT>

Related

CSS not loading in Jira server report

I am developing a jira server report and I am not able to load my css file.
In my atlassian-plugin.xml I define my web-resource like this:
<web-resource key="jira-reports-resources" name="wl-jira-report-plugin Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="jira-report-plugin.css" location="/css/jira-report-plugin.css"/>
<resource type="download" name="jira-report-plugin.js" location="/js/jira-report-plugin.js"/>
<resource type="download" name="images/" location="/images"/>
<context>jira-reports-context</context>
</web-resource>
and my report like this:
<report name="Massnahmen Verantwortlichkeit Report" i18n-name-key="report.massnahme.name"
key="massnahme-report" class="com.example.reports.massnahme.MassnahmeReport">
<description key="report.massnahme.description"></description>
<resource name="view" type="velocity" location="/templates/reports/massnahme/view.vm"/>
<resource name="i18n" type="i18n" location="report-massnahme"/>
<label key="report.massnahme.label"></label>
<!-- the properties of this report which the user must select before running it -->
<properties>
<property>
<key>departmentLeaderId</key>
<name>report.massnahme.input.user.name</name>
<description>report.massnahme.input.user.description</description>
<type>multiselect</type>
<values class="com.example.reports.massnahme.generator.MassnahmeUserGenerator"/>
</property>
</properties>
</report>
In my report java class I add the WebResourceManager into the velocityParams and in my view.vm I call it in the first row:
$webResourceManager.requireResourcesForContext("jira-reports-context")
In my view.vm I use a table-based presentation and I want to use a accordion technique to fold rows in my table. My javascript is loaded and the click listener works as intended. But my css file is completely ignored. When I inspect the page in chrome the css classes are not loaded at all. I tried some easy things like
.test-table{
border: 1px solid black;
}
and nothing is showing up.
How do I have to define my css class for using it in a report? I was surprised to see that I can not add css or javascript to the report element itself. Or do I have an error in my code definition? Any ideas?
Try this
webResourceManager.requireResource("groupId.artifactid:web-resource").
Example from the below link:
webResourceManager.requireResource("com.avvd.jira.plugin.inquirer:inquirer-resources")
https://community.atlassian.com/t5/Answers-Developer-Questions/Velocity-don-t-load-resource/qaq-p/489704
Thanks
Try not to use "-" in your context string, replace all the "-" with "."
<context>jira.reports.context</context>
and
$webResourceManager.requireResourcesForContext("jira.reports.context")
Even the answer was not quite correct, the link #MrKumar posted showed me the correct way. Apparently for CustomFields the approach using the method requireResource() is outdated and one should put these resources in <context>atl.general</context>. It worked directly with my reports too.

How to add more root level items to asp.net menu control?

Added a menu control and selected new datasource: SiteMapDataSource1
Here is my Web.sitemap so far:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Home.aspx" title="Home" description="Home Page">
<siteMapNode url="~/PostItem.aspx" title="Post Item" description="Post a new item" />
</siteMapNode>
</siteMap>
How can I add more root level items? I can create more siteMapNode's within the root level one that's already there, but if I add any outside of that it gives me an error. It makes sense to me why that would cause an error, but I'm thinking there's obviously a way to get the menu to display multiple root level menu items... but how?
--Edit--
If you want to build the Menu control with a xml data set, then you can have multiple nodes at the root level. This can be done via the designer and specifying MenuItems in the Items set of the Menu control, you can also add MenuItems to the Items list in the code behind, or bind it to an xml data set.
The MSDN has more information regarding this control. Code Project has a tutorial on using the xml data to build the Menu control.
--Original--
Sorry, you cannot add more than one root level siteMapNode. Typically you see that being the main entry point of the site (like you have it configured). Additional navigation is added from there.
Take a look at the MSDN for more information.

Binding unique URLs to XML site map ASP.NET

So, I'm new to ASP.NET and website development in general. I've run into a problem using data binding to an XML file to build a site map for an ASP.NET application. Here's the first portion of the sitemap:
<Privo>
<child display="Current Projects">
<child display="Amifostin">
<child display="Experiments">
<leaf>HTT</leaf>
<leaf>MTT</leaf>
<leaf>HPLC</leaf>
<leaf>UV-Spec</leaf>
</child>
And the data binding from the site.master file:
<DataBindings>
<asp:TreeNodeBinding DataMember="child" TextField="display" />
<asp:TreeNodeBinding DataMember="leaf" TextField="#InnerText" />
</DataBindings>
What'd I'd like to do it something like this:
<leaf url="ExperimentsView.aspx/HTT">HTT<leaf>
and
<asp:TreeNodeBinding DataMember="leaf" TextField="#InnnerText" NavigateUrl="url"/>
BUT, here's the problem: when I try to bind the NavigateUrl, the only thing I can do is bind a type of node to a url - meaning, every leaf will link the the same url. Is there a way to bind a field of the leaf nodes to a (unique) url, or will I have to make different DataMembers for each unique url?
Note: yes, I know about Web.sitemap. That's what I was using when the project lead told me that he wants to use XML data binding.
You will need to use the NavigateUrlField property to do this (see http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treenodebinding.navigateurlfield.aspx)

Can i put special characters like ® in the .resx file?

I have created a ProductResources.resx file. The name and value fields contain the ® character. THis is the R with a circle around it. It is a reg trademark. Obviously this needs to be there. An the resource file itself gives a red circle with a question mark inside it. Please help.
Depending on the encoding you declare for the resx XML, you can probably use one of the following:
® (iso-8859-1 or utf-8)
™ (unicode)
here's what you must do:
add a app_local_resources folder(right click on your project --> add asp.net folder)
name the resource folder as the following: PageName.aspx.resx
add the button name and property ( eg. Button1.Text) in the resource file name field
copy (by just highlight the registered trade mark from any source and copy it, paste in the value field from here
go to your button and add the following such as:
asp:Button ID="Button1" runat="server" Text="" onclick="Button1_Click" meta:resourcekey="Button1"
alt text http://img7.imageshack.us/img7/2108/59469768.jpg
hope this is what you want :)

Dynamically set the DefaultValue of a ParameterBinding in a DataFormWebPart

In my custom aspx page in WSS I am using a DataFormWebPart with an XSL file to render some data. In order to pass values to the XSL I use parameter bindings. Specifically, I need to pass in the server host URL like this:
<ParameterBinding
Name="HttpHost"
Location="CAMLVariable"
DefaultValue="http://hardcoded.com" />
This works fine, but the next thing I want to do is to get the host name dynamically. So figuring out how to get that from SharePoint I added the following binding:
<ParameterBinding
Name="HttpHost"
Location="CAMLVariable"
DefaultValue='<%# SPContext.Current.Site.Url.Replace
(SPContext.Current.Site.ServerRelativeUrl, "") %>' />
Now to the problem. The code works as expected if used some other place in the page, but with the above code SharePoint reports:
Web Part Error: The 'ParameterBindings' property of 'WebPartPages:DataFormWebPart'
does not allow child objects.
Anyone have a take on this?
I have enabled server side code according to SharePoint 2007: using ASP.NET server side code in your pages
After trying various methods of manipulating the ParameterBindings property without success I thought of how I could get the dynamic value in there using the Location attribute.
The ParameterBinding Location attribute refers to where to fetch the value from. Articles like this hints of the "Control()" option. So changing the parameter binding to:
<ParameterBinding
Name="HttpHost"
Location="Control(MyHttpHost, Text)"
DefaultValue="" />
and adding the following code to my page:
<asp:TextBox ID="MyHttpHost" runat="server" Visible="false" />
<script runat="server">
protected void Page_Load()
{
MyHttpHost.Text =
SPContext.Current.Site.Url.Replace(SPContext.Current.Site.ServerRelativeUrl, "");
}
</script>
...actually did the trick!
To get to the parameter values from within the accompanying XSL file I put param elements in the root element. The param name attribute must match that of the ParameterBinding:
<xsl:stylesheet ...>
...
<xsl:param name="HttpHost"/>
The parameter can then be referenced as any other XSL variable.

Resources