How can I initialize Content Picker for ReferenceGrid field control to display content from current workspace only?
<sn:ContextInfo runat="server" Selector="CurrentWorkspace" UsePortletContext="true" ID="myContext" />
<sn:ReferenceGrid ID="ReferenceGrid1" runat="server" FieldName="RelatedDocuments"
TreeRoots='<%# myContext.Path %>'/>
Thanks.
There's a property on the Reference Field called SelectionRoot. You can add it and change its value in the CTD xml of your ContentType
Related
I have two columns in a GridView where every cell of 1 column is hyperlinked.
<asp:GridView ID="gvBlogList" runat="server" DataKeyNames="Id"
AutoGenerateColumns="False" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLinkField DataTextField="id"
HeaderText="Blog id" NavigateUrl="detailspage.aspx" />
</ItemTemplate>
<ItemStyle Width="150px"></ItemStyle>
</asp:TemplateField>
</Columns>
</asp:GridView>
How can I get cell value in 2nd page as a session variable?
Thanks!
As per the what I understand from your question, you want to catch the value of the cell that is clicked, store it in session and make it accessible on the page that have redirect to. This is possible and you can try a flow like this :
You can use the GridView's inbuilt method onRowCommand in this case to generate a server side event and you can then identify which cell was clicked and lastly, you can get its value by index. The below code is a demonstration that you can try and manipulate as per your requirement. This is a sample where a Linkbutton is used in Gridview and on the click of it, its value is fetched.
You can also try to use the CommandName and CommandArgument properties if you want to assign that particular control a value that you may use at the server side.
protected void Grd1_RowCommand(object sender, GridViewCommandEventArgs e)
{
LinkButton lnk = (LinkButton)e.CommandSource;
string value = lnk.Text;
}
And for storing it in Session, you just have to make use of Session["yourVarName"] = value;. And this value can be accessed on the other page.
Hope this helps.
I have a Sitefinity 7.0 installation. I've added a custom content type, which includes a field for a single, required, image.
I created a custom template for this content type. On the site you can click on examples for how to add your fields to the widget template. This is what it gives me for the 'Picture' field:
<%--The following namespace should be registered at the top of the control if it doesn't exists--%>
<%# Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Modules.Libraries.Web.UI.Images" TagPrefix="sf" %>
<%# Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Modules.Libraries.Web.UI" TagPrefix="sf" %>
<sf:ImagesView ControlDefinitionName="ImagesFrontend" runat="server" MasterViewName="ImagesFrontendThumbnailsListLightBox" Title="" UrlKeyPrefix="">
<RelatedDataDefinition RelatedFieldName="Picture" RelatedItemType="Telerik.Sitefinity.DynamicTypes.Model.GIARRecipients.GiarRecipient" RelationTypeToDisplay="Child" RelatedItemSource="DataItemContainer">
</RelatedDataDefinition>
<ControlDefinition ControlDefinitionName="ImagesFrontend" runat="server" ProviderName="OpenAccessDataProvider">
<Views>
<sf:ImagesViewMasterDefinition SortExpression="" ViewName="ImagesFrontendThumbnailsListBasic" runat="server">
</sf:ImagesViewMasterDefinition>
<sf:ImagesViewMasterDefinition SortExpression="" ViewName="ImagesFrontendThumbnailsListLightBox" runat="server">
</sf:ImagesViewMasterDefinition>
<sf:ImagesViewMasterDefinition SortExpression="" ViewName="ImagesFrontendThumbnailsListSimple" runat="server">
</sf:ImagesViewMasterDefinition>
<sf:ImagesViewMasterDefinition SortExpression="" ViewName="ImagesFrontendThumbnailsListStrip" runat="server">
</sf:ImagesViewMasterDefinition>
<sf:ImagesViewDetailDefinition ViewName="ImagesDetailView" runat="server">
</sf:ImagesViewDetailDefinition>
</Views>
</ControlDefinition >
</sf:ImagesView>
This is way too much and the markup produced uses <ul><li>, even though it's always exactly one image. Ideally, I want it as simple as <img src='<%# Eval("Picture") %>' />
What is the simpliest way to add a single image to a Sitefinity template?
For the image fields on custom content types, you can limit the number of images by clicking on the "Limitations" tab when adding the field. Select "Only 1 image can be uploaded or selected"
.
The control that gets used in the template is instead is a Sitefinity Images control:
<sf:ImageControl runat="server" Title="" UrlKeyPrefix="" ProviderName="OpenAccessDataProvider" >
<RelatedDataDefinition RelatedFieldName="OneImage" RelatedItemType="Telerik.Sitefinity.DynamicTypes.Model.Solutions.Solution" RelationTypeToDisplay="Child" RelatedItemSource="DataItemContainer">
</RelatedDataDefinition>
</sf:ImageControl>
And the markup that gets rendered is a image tag wrapped in a div:
<div class="sfimageWrp">
<img id="ctl09_ctl00_ctl00_detailContainer_ctl03_0_ctl00_0_ctl00_0_imageItem_0" title="ootb" src="/images/default-source/default-album/ootb.png?sfvrsn=0" alt="ootb">
</div>
I choose Ben's answer as correct, but an alternative I found in the mean-time may also be worth mentioning.
<img src='<%# ((Telerik.Sitefinity.Libraries.Model.Image)Eval("Picture")).Url %>' />
I want to add 'All' option on top of other records fetched from database shown in dropdownlist.Any ideas on how to do this in vb.net 2005?
Think around the problem. Instead of adding the item to the combobox, add the item to the dynamic datasource.
Even in VS 2005 the AppendDataBoundItems property was available. So you can add this item programmatically from codebehind or declaratively on aspx:
<asp:DropDownList
runat="server"
ID="DropDownList1"
AppendDataBoundItems="true"
>
<asp:ListItem
Enabled="True"
Selected="True"
Text="All"
Value="0"
/>
</asp:DropDownList>
Now all your databound items are appended automatically and the first item will not be removed.
below worked for me!
Add a new row to datasource
Dim dr As DataRow = ds.Tables("cusPracticeLocation").NewRow
'Add some data to it
dr(0) = 0
dr(1) = "All"
ds.Tables("cusPracticeLocation").Rows.InsertAt(dr, 0)
New to VB.net, just trying to figure out how to properly manipulate the asp:Label control.
I have a page that, based on if there are results, etc should display an <h1></h1> tag with a header, then the data. As I am using the code-behind model, my user facing page essentially just has the following:
<asp:Label ID="lblMessage" runat="server"
Visible="false" />
<asp:DataList ID="dlCurriculumLists" runat="server"
DataSourceID="sdsCurriculumLists"
DataKeyField="Entry No_"
RepeatLayout="Flow"
Visible="false">
<ItemTemplate>
<div>
<asp:HyperLink ID="hlCurriculum" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "File Path") %>'
ToolTip='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
Target="_blank"
Style="font-weight: bold;">
</asp:HyperLink>
</div>
</ItemTemplate>
</asp:DataList>
On my code-behind page, I then set the asp:Label and asp:DataList to Visible="true" based on the data from the database. Here's the catch - if there is data, I want to set lblMessage to be an H1, and if not, just standard Label text. I realize I can emulate the look through the CSS, but was just hoping there was another way (maybe similar to the ItemTemplate concept) to specify the HTML type of the Label control - it appears to be a by default.
For people coming from a VB background, it's a common mistake to think that the most basic control for displaying arbitary text is a Label.
That's not true. A label should label something, usually another UI control (that's what the AssociatedControlId property is for).
If you just want to display arbitrary text or HTML markup, use something more basic instead. Some examples are asp:Literal, asp:Placeholder or asp:Localize.
Using, for example, an asp:Literal called myLiteral, you can easily create a heading in code:
myLiteral.Text = "<h1>" & Server.HtmlEncode(myHeading) & "</h1>"
As far as I know, the asp:Label component will always generate a <label> HTML tag when its AssociatedControlId attribute is set.
What you could do instead is use a Literal Control and populate it with the HTML you wish at runtime.
UPDATE
One thing you could do to make this work as required using your current Label control is to have a theme for the label that marks it up as a H1. You could then toggle the controls EnableTheming property as required.
Aside from what already has been suggested here, you can also implement your own ASP.NET control with any properties you want, then modify its rendering on the fly, depending on the properties' values. It is pretty fun to do and is not as hard as one might think. Here is some information on the subject: http://msdn.microsoft.com/en-us/library/vstudio/zt27tfhy(v=vs.100).aspx
I have a datagridview(dgv) with a DataGridViewComboBoxColumn(colLocation)
colLocation.AutoComplete = False
colLocation.HeaderText = "Stored to"
colLocation.DataSource = DB.getLocation()
colLocation.DisplayMember = "description"
colLocation.ValueMember = "id"
I added the colLocation to dgv.
"descirption" contains Unicode characters. I can see the comboBox correctly and choose the item.
The problem is when the comboBox lost the focus, the value is changed to first item of the comboBox.
Any suggestion?
Updated:
I found out that the ComboBox doesn't change the data when the DisplayMember is in English characters.
It changes only when the DisplayMember is in Unicode chracter. Any idea for how could solve this? – tunwn 0 secs ago
Your .aspx page should have something like so:
<asp:DropDownList Width="90px" ID="ddlExpenseTypes" OnSelectedIndexChanged="ddlExpenseTypes_SelectedIndexChanged" DataSource='<%# GetExpenseTypes() %>' SelectedValue='<%# Bind("ExpenseReasonID") %>' DataTextField="ExpenseReasonID" DataValueField="ExpenseReasonID" AutoPostBack="true" runat="server" ></asp:DropDownList>
That is you need a functional call for index changed. A function call for filling the drop down ist (DataSource) and a function call to set the SelectedValue of the drop down list.
Is this DataGridView databound? You haven't specified a value for DataPropertyName, so there's nothing for colLocation.ValueMember's ID selection to bind to.