Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
161 views

I am trying to pass an ItemTemplate from an instance of a user control to a ListView ItemTemplate in a user control.

------------------- USER CONTROL .ASCX.CS -------------------
    [TemplateContainer(typeof(ItemTemplateContainer))]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [TemplateInstance(TemplateInstance.Single)]
    public ITemplate ItemTemplate { get; set; }
    public class ItemTemplateContainer : Control, INamingContainer { }

    protected void Page_Init()
    {
        if (ItemTemplate != null)
        {
            ItemTemplateContainer container = new ItemTemplateContainer();
            ItemTemplate.InstantiateIn(container);
            //THIS IS WHERE I AM STUCK - HOW DO I ASSIGN THE TEMPLATE FROM .ASPX TO THE RADLISTVIEW HERE?
        }
        else
            //If no custom template specified load default
            RadListView1.ItemTemplate = Page.LoadTemplate("/someDefault/Standard.ascx");
    }

------------------- USER CONTROL INSTANCE .ASPX -------------------
<uc:MyControl ID="MyControl1" runat="server" >
    <ItemTemplate>
            ...unique template...
    </ItemTemplate>
</uc:MyControl>

Thanks,
Jeremy

Iana Tsolova
Telerik team
 answered on 08 Feb 2011
1 answer
96 views
I have created node dynamically
Aspx code:-
<telerik:RadTreeView ID="RadTreeViewCategory" runat="server" OnNodeExpand="RadTreeViewCategory_NodeExpand"
                    OnNodeDataBound="RadTreeViewCategory_NodeDataBound" AllowNodeEditing="true" OnNodeEdit="RadTreeViewCategory_NodeEdit">
                    <NodeTemplate>
                        <div style="float: left; padding-right: 10px;">
                            <asp:ImageButton ID="lnkEdit" runat="server" OnClientClick='<%# string.Format("return showItemDetail(\"{0}\", \"{1}\", \"{2}\");", Eval("ItemID"), SurvBenchHistID, Eval("IsReportCreated")) %>'
                                ImageUrl="~/images/EditIcon.gif" ImageAlign="Middle" ToolTip="Edit in New Screen" />
                            <asp:Label ID="lblname" runat="server" Text='<%# Eval("ReportItemShortText") %>' /></div>
                        <div style="float: right; padding-left: 40px;">
                            <asp:Label ID="lblImportance" runat="server" Text='<%# Eval("Importance") %>' Visible="false" />
                            <asp:Label ID="lblItemID" runat="server" Text='<%# Eval("ItemID") %>' Visible="false" />
                            <asp:CheckBox ID="chkOptional" runat="server" Visible="false" />
                            <asp:Label ID="lblReportItemText" runat="server" Text='<%#Eval("ReportItemText") %>'
                                Visible="false" />
                            <asp:DropDownList ID="ddlImportance" runat="server" />
                        </div>
                    </NodeTemplate>
                    <DataBindings>
                        <telerik:RadTreeNodeBinding Expanded="True" />
                    </DataBindings>
                </telerik:RadTreeView>

C#
protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
FillRadTree(dt);
}
}

private void FillRadTree(DataTable dt)
        {
            RadTreeViewCategory.DataTextField = "ReportItemShortText";
            RadTreeViewCategory.DataValueField = "ReportItemText";
            RadTreeViewCategory.DataFieldID = "ItemID";
            RadTreeViewCategory.DataFieldParentID = "ParentID";
            RadTreeViewCategory.DataSource = dt;
            RadTreeViewCategory.DataBind();
        }


protected void RadTreeViewCategory_NodeEdit(object sender, RadTreeNodeEditEventArgs e)
        {
            RadTreeNode nodeEdited = e.Node;
            string newText = e.Text;
            nodeEdited.Text = newText;
        }
Nikolay Tsenkov
Telerik team
 answered on 08 Feb 2011
5 answers
152 views
I've employed a technique similar to the one shown in this demo to create rich tooltips for my scheduler app.

My tooltip control has a toolbar in it. The toolbar has a OnClientButtonClicking event wired up. The tooltip also contains a RadScriptBlock with a correctly configured function to be called by the toolbar's OnClientButtonClicking event.

However, when my app runs and I hover over an event an error is generated along the lines of "ToolTipCommandItemClicking" is not defined.

Imagine my surprise.

After much messing about, I discovered that the only time the 'missing' JS function is found is if I move the definition out of the control used to create the tooltip and put it on the page containing the scheduler.

Whilst very odd, that wouldn't be the end of the world except for the fact that I can't call any other functions for detailing with the relevant toolbar button clicks which depend on the data loaded in to the tooltip control.

So, questions:
  1. Why won't the browser acknowledge that the called function does exist unless it is on the main page and not in the control used to populate the tooltip.
  2. How do I make it possible for the code that I have currently in the tooltip control to execute against the data loaded in the tooltip control itself?
For completeness, the markup for the control is show below.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CalendarEventToolTip.ascx.cs" Inherits="CalendarEventToolTip" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
    <script type="text/javascript">
      function ToolTipCommandItemClicking(sender, e) {
          var btn = e.get_item();
          var cmdName = btn.get_commandName();
   
          e.set_cancel(true);
          switch (cmdName) {
              case "Export":
                  Export();
                  break;
   
              case "Print":
                  break;
   
              case "Mail":
                  break;
   
              case "RequestInvite":
                  break;
          }
      }
 
        function Export() {
            var AjaxRequestObject = GetAjaxRequestObject("Export", "<%=this.GetType().ToString()%>");
            AjaxRequestJson(AjaxRequestObject);
        }
    </script>
</telerik:RadScriptBlock>
<telerik:RadToolBar ID='RadToolBar1'
                    runat='server'
                    OnClientButtonClicking='ToolTipCommandItemClicking'
                    Width='100%'>
  <Items>
    <telerik:RadToolBarButton CommandName="Export"
                              ImageUrl="ExportToOutlook"
                              ToolTip="Export this event to Outlook"/>
    <telerik:RadToolBarButton CommandName="Print"
                              ImageUrl="Print"
                              ToolTip="Print event details"/>
    <telerik:RadToolBarButton CommandName="Mail"
                              ImageUrl="Mail"
                              ToolTip="Send an email message to event organiser"/>
    <telerik:RadToolBarButton CommandName="RequestInvite"
                              ImageUrl="RequestInvite"
                              ToolTip="Request an invitation"/>
  </Items>
</telerik:RadToolBar>
<div style="margin:5px 5px 0px 5px; font-size:12px; padding-bottom: 10px;">
  <div style="border-bottom:solid 1px #ccc;margin-bottom:9px;font-size:11px;">
    Starting on: <asp:Label runat="server"
                            ID="StartingOn"></asp:Label>
  </div>
  <asp:Literal runat="server"
               ID="Subject"></asp:Literal>
  <asp:Literal runat="server"
               ID="Description"></asp:Literal>
</div>

-- 
Confused of Grantham
Svetlina Anati
Telerik team
 answered on 08 Feb 2011
1 answer
43 views
am getting error in documen t(1,2) while am attempting to bind a xml to radtreeview
Nikolay Tsenkov
Telerik team
 answered on 08 Feb 2011
1 answer
75 views
i want to set font property of all rad controls ... how can i do ?
Prangadj
Top achievements
Rank 1
 answered on 08 Feb 2011
1 answer
83 views
I am trying to use radmenu to create a custom looking menu that will have 2nd and 3rd level dropdowns.

I've attached an image of what the menu should look like.

My question is, what direction should I go with trying to do this?

I believe I could
1) go with no skin, and just try to override things with CSS declarations.
2) go with a custom skin, and try to build everything I want in terms of appearance into the custom skin
3) use all item templates and define the elements in there.

With my really limited knowledge of these topics I'm leaning toward using item templates, where I think I should be able to control the look of these things pretty well, but I may be wrong.

Can anyone give me some advice?
Cori
Top achievements
Rank 2
 answered on 08 Feb 2011
1 answer
70 views
I have what on the surface looks like a fairly simple scenario. I have a textbox validated by a radinputmanager via a webservice. This allows the user to enter a produce code. If the code is valid then I want to populate some values with the textboxes textchanged event.

Heres what I have:

<asp:TextBox ID="ProductReferenceTextBox" runat="server" Text='<%#Bind("ProductReference") %>' MaxLength="8"
                            AutoPostBack="true" OnTextChanged="ProductReferenceTextBox_TextChanged" />
 
<t:RadInputManager ID="MainInputManager" runat="server">
        <t:TextBoxSetting BehaviorID="ProductReferenceBehavior" Validation-Method="ValidateProductCode"
            Validation-Location="ValidationServices/ProductService.asmx" Validation-ValidateOnEvent="All" Validation-IsRequired="true" />
protected void ProductReferenceTextBox_TextChanged(object Sender, EventArgs E)
{
TextBox oSender = (TextBox)Sender;
 
if (IocContainer.ProductDao.Exists(oSender.Text))
{
  Product eProduct = IocContainer.ProductDao.GetProduct(oSender.Text);
 
    GridDataInsertItem oContainer = (GridDataInsertItem)oSender.NamingContainer;
 
  Label oLabel = (Label)oContainer.Controls[5].Controls[0];
 
  oLabel.Text = eProduct.StockUnit;
  }
  }

This is fine if the code entered is valid, but if the code is invalid (i.e. the webservice validation fails) I don't want to postback to the textchanged event.

Is there any way to do this?

Thanks
Martin
Telerik team
 answered on 08 Feb 2011
1 answer
44 views
Hi.
I'm developing an ASP.NET app using the Q1 2010 version.
The app is deployed in a testing server in the local network. I've a page with 2 raddatepicker. When I test in Firefox I've no problem, but when I work in I.E. 8 (with proxy with exceptions for local URL's) the second raddatepicker doesn't work (the popup button is like "disabled"). Curiously when I disable the proxy option in I.E. 8, the compatibility view is active (I can use it with proxy) and both raddatepicker works fine.
I try to use the microsoft support solution including several ways to use emulation in I.E 7 (using headers in IIS or metatags in aspx files) but nothing works with proxy on.
Any suggestion?

Arseni
Top achievements
Rank 1
 answered on 08 Feb 2011
1 answer
287 views
hello everyone,
I have stuck on the issue of changing the background color of rad-scheduler appointments, based on a value. My scenario is as,
I have a class named as <appointments> which contains the following properties StartDate,EndDate,TaskId,TaskName and Status.
The appointments class is the data source of scheduler.
I want to change the background -color of appointments compairing the values in status field, but at the same time status should not be shown.
advance thnx.

scheuler.ascx
<telerik:RadScheduler ID="calTaskDisplay" runat="server" DataEndField="EndDate" DataKeyField="TaskId"
                    DataStartField="EndDate" DataSubjectField="TaskName" OnAppointmentCreated="calTaskDisplay_AppointmentCreated"
                    OnDataBound="calTaskDisplay_DataBound" AllowDelete="False" AllowEdit="False" SelectedView="MonthView"
                    DayStartTime="09:00:00" DisplayDeleteConfirmation="False" EditFormDateFormat="d/M/yyyy"
                    EnableAdvancedForm="False" EnableViewState="False" FirstDayOfWeek="Monday" LastDayOfWeek="Friday"
                    WorkDayEndTime="17:00:00" EnableCustomAttributeEditing="true" CustomAttributeNames="status"
                    WorkDayStartTime="09:00:00" OnAppointmentDataBound="calTaskDisplay_AppointmentDataBound">
                    <DayView DayStartTime="09:00:00" ShowHoursColumn="False" WorkDayEndTime="17:00:00" />
                    <WeekView DayStartTime="09:00:00" WorkDayStartTime="09:00:00" WorkDayEndTime="17:00:00" />
                    <AppointmentTemplate>
                        <%#Eval("Subject")%>
                        <input type="text" id="lblStatus" visible="false" title='<%# Eval("Status") %>' />
                    </AppointmentTemplate>
                </telerik:RadScheduler>

codebehind as,
scheduler.ascx.cs
Page_Load()
{
List<ScheduledTasks> loOtherTasks = loClient.GetScheduledTasks(Session["UserId"].ToString());
                calTaskDisplay.DataSource = loOtherTasks;
                calTaskDisplay.DataBind();
}
calTaskDisplay_AppointmentDataBound(object sender, SchedulerEventArgs e)
{
 switch (e.Appointment.Attributes["Status"])
            {
                case "Pending": e.Appointment.BackColor = System.Drawing.Color.Red;
                    break;
                case "pending": e.Appointment.BackColor = System.Drawing.Color.Red;
                    break;
                case "Complete": e.Appointment.BackColor = System.Drawing.Color.Green;
                    break;
                case "complete": e.Appointment.BackColor = System.Drawing.Color.Green;
                    break;
                case "Over due": e.Appointment.BackColor = System.Drawing.Color.Red;
                    break;
                case "over due": e.Appointment.BackColor = System.Drawing.Color.Red;
                    break;
                case "Started": e.Appointment.BackColor = System.Drawing.Color.Blue;
                    break;
                case "started": e.Appointment.BackColor = System.Drawing.Color.Blue;
                    break;
                default:
                    break;
}
 
calTaskDisplay_DataBound(object sender, EventArgs e)
{
foreach (ResourceType resType in calTaskDisplay.ResourceTypes)
            {
                resType.AllowMultipleValues = false;
            }
}
Princy
Top achievements
Rank 2
 answered on 08 Feb 2011
1 answer
234 views
Hi,

I have two questions regarding opening a rad window.  Please note in both scenario's I don't want to use the radalert or radconfirm dialog boxes, I want to be able to display my own message box.

First question, I have a page with a radgrid and am using linkbuttons in the CommandItemTemplate to perform add/updates/deletes and everything works great. When a user adds a new record, I perform validation that checks for a duplicate value against the database or a null value.  If a duplicate'null value is found then I open a radwindow that displays a message to the user that a duplicate/null value has been found and again this works great. The problem is that when the radwindow opens a postback occurs.  I don't want this to happen.

I have read the article Calling radalert from codebehind (all versions of RadWindow) and cannot figure out how top apply this to my code.  The scenario where I am calling the radwindow is a little different.  The code that opens the the rad window is in another module.

Here is the code that calls the radwindow;
<CommandItemTemplate >
                   <div style="padding: 5px 5px;">
                       <asp:LinkButton ID="lbtAdd"          runat="server" CommandName="InitInsert"     Visible='<%# Not rgvSecurityGroups.MasterTableView.IsItemInserted %>'><asp:Image ID="imgAdd" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,AddGreen16%>" /> Add </asp:LinkButton>  
                       <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected"   Visible='<%# rgvSecurityGroups.EditIndexes.Count = 0 and Not rgvSecurityGroups.MasterTableView.IsItemInserted %>'>          <asp:Image runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images, EditGreen16%>"/> Edit </asp:LinkButton>  
                       <asp:LinkButton ID="btnCancel"       runat="server" CommandName="CancelAll"      Visible='<%# rgvSecurityGroups.EditIndexes.Count > 0 Or rgvSecurityGroups.MasterTableView.IsItemInserted %>'><asp:Image ID="imgCancel" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,CancelGreen16%>" /> Cancel </asp:LinkButton>  
                       <asp:LinkButton ID="lbtSaveNew"      runat="server" CommandName="PerformInsert"  Visible='<%# rgvSecurityGroups.MasterTableView.IsItemInserted%>'><asp:Image ID="imgSaveNew" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,SaveButton18%>" /> Save New</asp:LinkButton>  
                       <asp:LinkButton ID="lbtDelete"       runat="server" CommandName="DeleteSelected" Visible='<%# rgvSecurityGroups.EditIndexes.Count = 0 and Not rgvSecurityGroups.MasterTableView.IsItemInserted %>'><asp:Image ID="imgDelete"       runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,DeleteRed16%>" />Delete </asp:LinkButton>  
                       <asp:LinkButton ID="lbtSave"         runat="server" CommandName="UpdateEdited"   Visible='<%# rgvSecurityGroups.EditIndexes.Count > 0 or rgvSecurityGroups.MasterTableView.IsItemInserted%>'><asp:Image runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,SaveBlue16%>" />  Update </asp:LinkButton>  
                       <asp:LinkButton ID="lbtRefresh"      runat="server" CommandName="RebindGrid"     ><asp:Image id="imgRefresh" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$Resources:Images, ReloadBlue16 %>" AlternateText ="Refresh Grid" /></asp:LinkButton>                     
                   </div>
               </CommandItemTemplate>


Private Sub rgvSecurityGroups_InsertCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgvSecurityGroups.InsertCommand
    Dim InsertedItem As GridDataInsertItem = DirectCast(e.Item.OwnerTableView.GetInsertItem(), GridDataInsertItem)
    Dim strSecurityGroup As String = DirectCast(InsertedItem("SecurityGroup").Controls(0), TextBox).Text
    Dim aryParameters(2) As String
    Dim strMessageType As String = Nothing
    Dim strMessage As String = Nothing
    Dim strMessageHeading As String = Nothing
    If strSecurityGroup Is Nothing Or IsDBNull(strSecurityGroup) Or Len(strSecurityGroup) = 0 Then
        strMessageType = "Error"
        strMessageHeading = "Null Value"
        aryParameters(0) = "Security Group"
        aryParameters(1) = strSecurityGroup
        strMessage = UDF_GetErrorMessage("Null Value", aryParameters)
        USB_DisplayMessage(strMessageType, strMessageHeading, strMessage, "Medium", "Black", Me.rwmMessageBox)
    Else
        If pUDF_DuplicateValueCheck(0, strSecurityGroup) = True Then
            strMessageType = "Error"
            strMessageHeading = "Duplicate Value"
            aryParameters(0) = "Security Group"
            aryParameters(1) = strSecurityGroup
            strMessage = UDF_GetErrorMessage("Duplicate Value", aryParameters)
            USB_DisplayMessage(strMessageType, strMessageHeading, strMessage, "Medium", "Black", Me.rwmMessageBox)
        Else
            Me.SQLDS_SecurityGroups.InsertCommandType = SqlDataSourceCommandType.Text
            Me.SQLDS_SecurityGroups.InsertCommand = "EXEC [Security].[DSP_SEL-INS-UPD-DEL-SecurityGroups] 'Insert', DEFAULT, " & strSecurityGroup
        End If
    End If

Here's is the code that opens the rad window, notice that I am sending the radwindow control that is used on the page that is calling the procedure.
Public Shared Sub USB_DisplayMessage(ByVal strMessageType As String, ByVal strMessageHeading As String, ByVal strMessage As String, ByVal strMessageSize As String, ByVal strSkin As String, ByVal rwmMessageBox As RadWindowManager)
       Dim rwdMessage As New RadWindow
       Dim strNavigation As String = "~/Modules/Central/WBF CTL Message Box.aspx?MessageType=" + strMessageType + "&MessageHeading=" + strMessageHeading + "&Message=" + strMessage
       rwdMessage.ID = "rwdMessageDetail"
       rwdMessage.Skin = strSkin
       Select Case strMessageSize
           Case "Small"
               rwdMessage.Height = "250"
               rwdMessage.Width = "400"
           Case "Medium"
               rwdMessage.Height = "300"
               rwdMessage.Width = "400"
       End Select
       rwdMessage.NavigateUrl = strNavigation
       rwmMessageBox.Windows.Add(rwdMessage)
   End Sub

So my question is how do I prevent the radwidow from causing a postback?

My second question is regarding the cancelling of the delete event.  As in the above scenario I am using the CommandItemTemplate with LinkButtons to perform all the record functions.  When the user clicks the delete button I open a radwindow prompting  (yes/no buttons)  them to confirm the deletion and again this works fine.  What I want to be able to do is Cancel the deletion if the user clicks the No button on the rad window.  But I can't figure out how to cancel the DeleteCommand if the user clicks the No button to cancel the deletion.

Here is the code that calls the rad window. The code for opening the rad window is the same as listed above.

Private Sub rgvSecurityGroups_DeleteCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgvSecurityGroups.DeleteCommand
    Dim GridItem As GridDataItem = DirectCast(e.Item, GridDataItem)
    Dim intSecurityId As Int16 = GridItem.GetDataKeyValue("SecurityID")
    Dim strSecurityGroup As String = GridItem("SecurityGroup").Text
    Dim strMessageType As String = Nothing
    Dim strMessage As String = Nothing
    Dim strMessageHeading As String = Nothing
    strMessageType = "Warning"
    strMessageHeading = "Deleting " + strSecurityGroup
    strMessage = "You have selected to delete security group " + strSecurityGroup & ".  This action will cause this group to be deleted from all Users.<br><br>Do you want to continue?"
    USB_DisplayMessage(strMessageType, strMessageHeading, strMessage, "Medium", "Black", Me.rwmMessageBox)
    Me.SQLDS_SecurityGroups.DeleteCommandType = SqlDataSourceCommandType.Text
    Me.SQLDS_SecurityGroups.DeleteCommand = "EXEC [Security].[DSP_SEL-INS-UPD-DEL-SecurityGroups] 'Delete', " & intSecurityId & ", DEFAULT"
End Sub

Thank you for your help.

Georgi Tunev
Telerik team
 answered on 08 Feb 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?