SharePoint XSLT Column Display Name - sharepoint

I currently try to display the column name in a custom form in SharePoint Designer. I use Sharepoint 2013 so the design view doesnt exists anymore :(.
The form is used to create a new element in a custom list.
I cant put the name directly in the tempate because i would like use this template in different forms so i have to recover the name of my columns dynamically.
The problem is that I only found the internal name.
I saw in the datafileds tag there are couples where the internal name is relied to the display name but I didnt find how recover the display name with that too.
Is it only possible ? Someone has an idea to help me?
I put some code if u want to look at my code.
This part looks for an attribute where the name contains "question" and calls the template "title_line" when it finds one. The function name() gives me the internal name, that is the pb...
<xsl:template match="Row">
<xsl:for-each select="#*">
<xsl:choose>
<xsl:when test="contains(name(),'Question')">
<xsl:call-template name="title_line" >
<xsl:with-param name="title" select="name()"/>
<xsl:with-param name="class" select="'class_title'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
This part is to display the title:
<xsl:template name="title_line" >
<xsl:param name="title" select="'no title'" />
<xsl:param name="class" select="'no_class'" />
<tr>
<td colspan ="2" class="{$class}" style="font-weight:bold;font-size:medium">
<xsl:value-of select="$title" />
</td>
</tr>
</xsl:template>
MY SOLUTION :
I used JQuery 1.9.0 and SPServices 0.7.2
Import these libraries into the header.
The ContentPlacdeHolderId PlaceHolderAdditionalPageHead is at the bottom of the page, i didnt see it and have some problems because of the duplicate...)
About the source, i activated the publishing and create a folder Scripts into the Styles Library.
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="FormCustomRedirectControl" AllowMultipleControls="true"/>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
<SharePoint:CssRegistration Name="forms.css" runat="server"/>
<!-- add JQuery 1.9.0-->
<script id ="JQUERY_ID" type="text/javascript" src="../../Style%20Library/Scripts/jquery-1.9.0.js">
</script>
<!-- add SPServices 0.7.2 -->
<script id ="JQUERY_ID" type="text/javascript" src="../../Style Library/Scripts/jquery.SPServices-0.7.2.js">
</script>
</ContentTemplate>
</SharePoint:UIVersionedContent>
</asp:Content>
Now the display of the title is :
<xsl:template name="title_line" >
<xsl:param name="title" select="'no title'" />
<xsl:param name="class" select="'no_class'" />
<tr>
<td colspan ="2" class="{$class}" style="font-weight:bold;font-size:medium">
<script type="text/javascript">
var static_name = &apos;<xsl:value-of select="$title" />&apos;;
var display_name = $().SPServices.SPGetDisplayFromStatic ({
listName: "listeperso",
columnStaticName: static_name
});
document.write(display_name);
</script>
</td>
</tr>
</xsl:template>
I just need to have the name of the list dynamically and it's over.
Cya.
EDIT : the script with the list name dynamically
<script type="text/javascript">
var list_name = $().SPServices.SPListNameFromUrl();
var static_name = &apos;<xsl:value-of select="$title" />&apos;;
var display_name = $().SPServices.SPGetDisplayFromStatic ({
listName : list_name,
columnStaticName: static_name
});
document.write(display_name);
</script>
listName uses either the list name either the list ID. SPListNameFromUrl returns the list ID.

I see anybody have an idea.
I find a Javascript library SPServices which can convert the static name t the display name.
Link
My new is to integrate the script. I tried to put it into the header like that :
<asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<script type="text/javascript" src="../../Style%20Library/Scripts/jquery-1.9.0.js">
</script>
<script type="text/javascript" >
var azerty="jquery script";
alert($azerty);
$(document).ready(function() {
alert("jQuery");
});
</script>
</asp:Content>
But the import doesnt appear into the generated page. Someone has an idea ?

I used JQuery 1.9.0 and SPServices 0.7.2
Import these libraries into the header.
The ContentPlacdeHolderId PlaceHolderAdditionalPageHead is at the bottom of the page, i didnt see it and have some problems because of the duplicate...)
About the source, i activated the publishing and create a folder Scripts into the Styles Library.
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="FormCustomRedirectControl" AllowMultipleControls="true"/>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
<SharePoint:CssRegistration Name="forms.css" runat="server"/>
<!-- add JQuery 1.9.0-->
<script id ="JQUERY_ID" type="text/javascript" src="../../Style%20Library/Scripts/jquery-1.9.0.js">
</script>
<!-- add SPServices 0.7.2 -->
<script id ="JQUERY_ID" type="text/javascript" src="../../Style Library/Scripts/jquery.SPServices-0.7.2.js">
</script>
</ContentTemplate>
</SharePoint:UIVersionedContent>
</asp:Content>
Now the display of the title is :
<xsl:template name="title_line" >
<xsl:param name="title" select="'no title'" />
<xsl:param name="class" select="'no_class'" />
<tr>
<td colspan ="2" class="{$class}" style="font-weight:bold;font-size:medium">
<script type="text/javascript">
var static_name = &apos;<xsl:value-of select="$title" />&apos;;
var display_name = $().SPServices.SPGetDisplayFromStatic ({
listName: "listeperso",
columnStaticName: static_name
});
document.write(display_name);
</script>
</td>
</tr>
</xsl:template>
I just need to have the name of the list dynamically and it's over.
Cya.
EDIT : the script with the list name dynamically
<script type="text/javascript">
var list_name = $().SPServices.SPListNameFromUrl();
var static_name = &apos;<xsl:value-of select="$title" />&apos;;
var display_name = $().SPServices.SPGetDisplayFromStatic ({
listName : list_name,
columnStaticName: static_name
});
document.write(display_name);
</script>
listName uses either the list name either the list ID. SPListNameFromUrl returns the list ID.

Related

Password visible in ext.net user control

User control (ascx) with a password input. Right-click, inspect - the value is visible. This doesn't happen if the password input is in an aspx.
Hmm, it seems I have to add some ramblings here, since the platform won't allow me to post this thread due to "mostly code".
Default.aspx
<%# Page Language="C#" %>
<%# Register Src="UserPassword.ascx" TagName="UserPass" TagPrefix="uc" %>
<script runat="server">
protected void Page_Load( object sender, EventArgs e )
{
if ( !X.IsAjaxRequest )
{
this.BindUser();
}
}
public void BindUser()
{
userPass1.UserName = "AliBaba";
userPass1.Password = "OpenSesame";
}
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Password inspect bug</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:Window
ID="Window1"
runat="server"
Icon="User"
Closable="false"
Title="Customer Details"
Width="350"
Height="230"
Resizable="false"
BodyStyle="background-color:#fff;"
BodyPadding="5"
Layout="Anchor">
<Items>
<ext:Panel ID="panel1" runat="server" Header="false" Layout="FitLayout">
<Content>
<uc:UserPass ID="userPass1" runat="server"></uc:UserPass>
</Content>
</ext:Panel>
</Items>
</ext:Window>
</form>
</body>
</html>
UserPassword.ascx
<%# Control Language="C#" %>
<script runat="server">
public string UserName
{
get { return this.txtUser.Text; }
set { this.txtUser.Text = value; }
}
public string Password
{
get { return this.txtPassword.Text; }
set { this.txtPassword.Text = value; }
}
</script>
<ext:Panel ID="panel1" runat="server" BodyPadding="5" Layout="AnchorLayout">
<Items>
<ext:Panel ID="panel2" runat="server" Border="false" Header="false" AnchorHorizontal="100%" Layout="FormLayout">
<Items>
<ext:TextField ID="txtUser" runat="server" FieldLabel="User" />
<ext:TextField ID="txtPassword" runat="server" FieldLabel="Password" InputType="Password" />
</Items>
</ext:Panel>
</Items>
</ext:Panel>
Are there any known workarounds?
Short answer: Use this.txtPassword.setValue(value) not this.txtPassword.Text = value to fix your direct problem.
Long answer: Why you are setting the password from the server? Best practice states that passwords are stored as hashes on the server so you don't actually know a users real password, you are just comparing two hashes.
public string Password
{
get { return this.txtPassword.Text; }
set { this.txtPassword.Text = value; }
}
If you want to autofill a password, which i assume you do, you need to use a cookie.
if (Request.Cookies["username"] != null)
{
this.txtUsername.setValue(Request.Cookies["uid"].Value);
this.txtPassword.setValue(Request.Cookies["pwd"].Value);
}

XSLT for selecting specific values in filtered nodes

I have a XML structure where i need to apply filtering for nodes and out of the filtered nodes i need to select specific elements. The structure of actual XML looks like this-
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
....
<elementn>Price0</elementn>
<Menu>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
....
<elementn>Price1</elementn>
<Menu>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
....
<elementn>Price2</elementn>
<Menu>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
....
<elementn>Price3</elementn>
<Menu>
<NodeD>
<Element1>type4</element1>
<Element2>Vegetables</Element2>
....
<Elementn>Price4</elementn>
</NodeD>
</Menu>
</NodeC>
</Menu>
</NodeB>
</Menu>
</NodeA>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
....
<elementn>Price5</elementn>
<Menu>
<NodeF>
<element1>type6</element1>
<element2>Vegetables</element2>
....
<elementn>Price6</elementn>
</NodeF>
</Menu>
</NodeE>
</Menu>
</Host>
Now I have filtered this XML as follows-
a) if <element2> == fruits in all the nodes, the XML result is -
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
....
<elementn>Price0</elementn>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
....
<elementn>Price1</elementn>
</NodeA>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
....
<elementn>Price2</elementn>
</NodeB>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
....
<elementn>Price3</elementn>
</NodeC>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
....
<elementn>Price5</elementn>
</NodeE>
</Host>
XSLT used for getting the above result is-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:param name="element2" select="'Fruits'" />
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates select="//*[element2=$element2]" mode="copy"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[element2]" mode="copy">
<xsl:copy>
<xsl:apply-templates select="*[not(*)]" mode="copy"/>
</xsl:copy>
</xsl:template>
<xsl:template match="#*|node()" mode="copy">
<xsl:copy>
<xsl:apply-templates select="#*|node()" mode="copy"/>
</xsl:copy>
</xsl:template>
The above XSLT select all the elements in the node where <element2> = Fruits condition is applied. Now I need to select specific elements in each filtered node (<Host>, <NodeA>, <NodeB>, <NodeC>, <NodeE>) - say for every node, i have elements range from to . Now I want to select only and from filtered nodes (<Host>, <NodeA>, <NodeB>, <NodeC>, <NodeE>). Also the expected output format is given below. The two values in each given below is from and of each node.
<html>
<head>
<body>
<table border="1">
<tr>
<td>type0</td>
<td>Price0</td>
</tr>
<td>type1</td>
<td>Price1</td>
</tr>
<tr>
<td>type2</td>
<td>Price2</td>
</tr>
<tr>
<td>type3</td>
<td>Price3</td>
</tr>
<tr>
<td>type5</td>
<td>Price5</td>
</tr>
</table>
</body>
</head>
</html>
Any help would be a great plus.
It seems you want to do something like:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="element2" select="'Fruits'" />
<xsl:template match="/">
<html>
<head/>
<body>
<table border="1">
<xsl:for-each select="//*[element2=$element2]">
<tr>
<td>
<xsl:value-of select="element1" />
</td>
<td>
<xsl:value-of select="elementn" />
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
When this is applied to the following well-formed (!) input:
XML
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
<elementn>Price0</elementn>
<Menu>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
<elementn>Price1</elementn>
<Menu>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
<elementn>Price2</elementn>
<Menu>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
<elementn>Price3</elementn>
<Menu>
<NodeD>
<element1>type4</element1>
<element2>Vegetables</element2>
<elementn>Price4</elementn>
</NodeD>
</Menu>
</NodeC>
</Menu>
</NodeB>
</Menu>
</NodeA>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
<elementn>Price5</elementn>
<Menu>
<NodeF>
<element1>type6</element1>
<element2>Vegetables</element2>
<elementn>Price6</elementn>
</NodeF>
</Menu>
</NodeE>
</Menu>
</Host>
the result will be:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table border="1">
<tr>
<td>type0</td>
<td>Price0</td>
</tr>
<tr>
<td>type1</td>
<td>Price1</td>
</tr>
<tr>
<td>type2</td>
<td>Price2</td>
</tr>
<tr>
<td>type3</td>
<td>Price3</td>
</tr>
<tr>
<td>type5</td>
<td>Price5</td>
</tr>
</table>
</body>
</html>
rendered as:

Colorpicker doesn't work

i use Liferay 6.1, I created a portlet with code (Link: http://www.liferay.com/community/wiki/-/wiki/Main/Using+Lifery+provided+Color+Picker+in+Own+Portlets)
<script type="text/javascript"> jQuery( function() { var colorPicker = new Liferay.ColorPicker( { hasImage: true } ); } ); </script>
<tr> <td> <input class="text-input" id="color" name="color" size="9" type="text" value="" />
<img align="absmiddle" alt="<liferay-ui:message key="color" />" border="0" class="use-color-picker" height="18" hspace="0" src="<%= themeDisplay.getPathThemeImages() %>/color.png" title="<liferay-ui:message key="color" />" vspace="0" width="18" style="cursor: pointer;" />
</input> </td> </tr>
but it doesn't work, please help me :)
You need to pass more options to new Liferay.ColorPicker . According to the guide you posted:
Options:
•context (Object): A DOM object which specifies the context in which
to search for the item
•hasImage: (Boolean) If set to true, it uses
the "item" param or whatever image has the .use-color-picker class as
the image
•item: (Object|String): A DOM object or a jQuery Selector
string that specifies which field to insert the selected value into
•onChange (Function): A function that will get called whenever the
color changes
•onClose (Function): A function that will get called
when the color picker is closed.

Ext.NET 2.0 how to get the value of datefield

I want to get from datefield. Ext.NET 2.0 is a little bit difficult to study.
This is a source of simple datefield.
<ext:DateField ID="DateField1" runat="server"
Vtype="daterange" FieldLabel="To" EnableKeyEvents="true" />
and I'd like to set the value on my Textbox.
myTextbox.setValue(App.MainContent_DateField1.getValue());
help!!
Just found the answer to this - using getRawValue() function
myTextbox.setValue(App.MainContent_DateField1.getRawValue());
I tested the basic scenario and it appears to work correctly.
You might need to call .format() to convert your DateField value into a nicely formatted string, but that is not required.
Here's a full sample demonstrating the scenario. Select a Date from the DateField, then click the Button. The DateField value will be copied to the TextField.
Example
<%# Page Language="C#" %>
<%# Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:DateField ID="DateField1" runat="server" />
<ext:TextField ID="TextField1" runat="server" />
<ext:Button
runat="server"
Text="Submit"
OnClientClick="TextField1.setValue(DateField1.getValue().format('d-M-Y'));"
/>
</form>
</body>
</html>

how to use the updatepanl and postback trigger and progress templete in asp.net ajax

hi i am using update panel in my project, one page i have file upload control is there, so save the page file upload is not working that time i used post back trigger control (id is button id) now my problem is progress bar is not working , please give me any suggestion. my code is
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="IBtnSave" />
<asp:PostBackTrigger ControlID="ddlAgent" />
<asp:PostBackTrigger ControlID="btnSelectCity" />
<asp:PostBackTrigger ControlID="imgBtnAgent" />
<asp:PostBackTrigger ControlID="ImgBtnCancel" />
</Triggers>
progress bar code is
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="up1"
DynamicLayout="true">
<ProgressTemplate>
<div id="Progressbar" class="Progressbar" align="center" valign="middle" runat="server">
<asp:Image ID="Image1" Width="75" Height="95" runat="server" ImageUrl="~/images/animation_processing.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
how to solve that problem, please give me any suggestion
Thank u
hemanth
i can find out the answer it is working
just write the java script like this
<script type="text/javascript">
var updateProgress = null;
function postbackButtonClick() {
updateProgress = $find("<%= UpdateProgress1.ClientID %>");
window.setTimeout("updateProgress.set_visible(true)", updateProgress.get_displayAfter());
return true;
}
</script>
after that
<asp:UpdatePanel runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="IBtnSave" />
</Triggers>
button onclick event just call that function like this
<asp:Button ID="IBtnSave" runat="server" Text="Save" CssClass="art-button"
ClientIDMode="Static" onclick="IBtnSave_Click" OnClientClick="return postbackButtonClick();"/>

Resources