Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
90 views
I need to validate the advanced form serverside and there are a few things that I need to do that cannot be done with asp validators.  I am already using asp validators for some required fields and I'd like to use them here, if possible to simply things.

Specifically I need to:
1) I need to verify that a RadNumericTextbox is a multiple of 6
2) Check a repeater and make sure that its Items.Count are > 0.

How can I do these 2 validations? 

Steven
Plamen
Telerik team
 answered on 13 Aug 2012
3 answers
318 views
Hi,

I am using template coulmn and adding required field validator and span tag to show * in red color.
I am struggling eith the allignment of the same. Please find attached the images depecting few cases.
I have tried adding br tag after span tag, after required field etc but it is not alligned properly.

All I am trying to implement is to have a Red * in the initial load of the page and required field error message on next line. I also need to take care of the scenario of people working on different resolution screen. I have 5 required fields.

<telerik:GridTemplateColumn HeaderText="Site ID" DataField="SiteID" UniqueName="SiteID"
                        EditFormColumnIndex="0" SortExpression="SiteID" AllowFiltering="true">
                        <EditItemTemplate>
                            <telerik:RadTextBox runat="server" ID="txtSiteId" Text='<%# Bind("SiteID") %>' MaxLength="50">
                            </telerik:RadTextBox>
                            <span style="color: red">*</span>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidatorSiteId" runat="server" ErrorMessage="Site Id is Required"
                                ControlToValidate="txtSiteId" ValidationGroup="requiredFieldGroup">
                            </asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <%#Eval("SiteID")%>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
Kostadin
Telerik team
 answered on 13 Aug 2012
4 answers
227 views

here is my aspx code

Page Language="VB" MasterPageFile="~/internal1.master" AutoEventWireup="false" CodeFile="objectType.aspx.vb" Inherits="internal_parameter_catalog_objectType" title="Untitled Page" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <telerik:radscriptblock id="RadScriptBlock1" runat="server">
                <script type="text/javascript">
                    //On insert and update buttons click temporarily disables ajax to perform upload actions
                    function conditionalPostback(e, sender)
                    {
                        var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
                  if (sender.EventTarget.match(theRegexp))
                  {
                      var upload = $find(window['UploadId']);
                     
                      //AJAX is disabled only if file is selected for upload
                      if(upload.getFileInputs()[0].value != "")
                      {
                          sender.EnableAjax = false;
                      }
                  }
                    }    
                </script>
            </telerik:radscriptblock>
           
           
    <span style="font-size: 16pt; font-family: 新細明體"><strong><em>館藏類型編輯作業</em></strong></span>
        <br /><br />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" Style="position: static">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
        Style="position: static" Transparency="50" Width="75px">
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
            style="border: 0px;" />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"
        clientevents-onrequeststart="conditionalPostback">
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
        AllowAutomaticUpdates="True" AllowMultiRowEdit="True" AllowMultiRowSelection="True"
        AllowPaging="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
        GridLines="None" PageSize="25" ShowStatusBar="True" Skin="Office2007" Style="position: static">
        <PagerStyle Mode="NextPrevNumericAndAdvanced" Position="TopAndBottom" />
        <MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="itemtype" DataSourceID="SqlDataSource1" GridLines="None" NoDetailRecordsText="系統裡沒有子資料" NoMasterRecordsText="系統裡沒有資料">
            <RowIndicatorColumn>
                <HeaderStyle Width="20px" />
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px" />
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
                    <HeaderTemplate>
                        <asp:CheckBox ID="headerChkbox" runat="server" AutoPostBack="True" OnCheckedChanged="ToggleSelectedState"
                            Style="position: static" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="ToggleRowSelection"
                            Style="position: static" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="itemtype" HeaderText="類型代碼" ReadOnly="True" SortExpression="itemtype"
                    UniqueName="itemtype">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="description" HeaderText="館藏類型" SortExpression="description"
                    UniqueName="description">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="createdate" DataType="System.DateTime" HeaderText="建檔日期"
                    SortExpression="createdate" UniqueName="createdate">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="createname" HeaderText="建檔人" SortExpression="createname"
                    UniqueName="createname">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="storeno" HeaderText="所屬館藏" SortExpression="storeno"
                    UniqueName="storeno">
                </telerik:GridBoundColumn>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelText="放棄" EditText="修改" InsertText="儲存新增" UpdateText="儲存修改">
                </telerik:GridEditCommandColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="删除"
                    UniqueName="column" ConfirmText="資料將被删除,請確認!" ConfirmTitle="資料删除確認">
                </telerik:GridButtonColumn>
            </Columns>
            <CommandItemTemplate>
                <asp:LinkButton ID="btnEditSelected" runat="server" CausesValidation="false" CommandName="EditSelected"
                    Style="vertical-align: bottom; position: static" Visible="<%# RadGrid1.EditIndexes.Count = 0 %>"><img style="border:0px;vertical-align:middle;" alt="" src="../../../pics/action/Edit.gif" /> 修改選取資料</asp:LinkButton><asp:LinkButton
                        ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Style="position: static"
                        Visible="<%# RadGrid1.EditIndexes.Count > 0 %>"><img style="border:0px;vertical-align:middle;" alt="" src="../../../pics/action/Update.gif" /> 儲存修改資料</asp:LinkButton><asp:LinkButton
                            ID="btnCancel" runat="server" CausesValidation="false" CommandName="CancelAll"
                            Style="position: static" Visible="<%# RadGrid1.EditIndexes.Count > 0 Or RadGrid1.MasterTableView.IsItemInserted %>"><img style="border:0px;vertical-align:middle;" alt="" src="../../../pics/action/Cancel.gif" /> 放棄編輯</asp:LinkButton><asp:LinkButton
                                ID="LinkButton2" runat="server" CommandName="InitInsert" Style="position: static"
                                Visible="<%# Not RadGrid1.MasterTableView.IsItemInserted %>"><img style="border:0px;vertical-align:middle;" alt="" src="../../../pics/action/AddRecord.gif" /> 新增資料</asp:LinkButton><asp:LinkButton
                                    ID="LinkButton3" runat="server" CommandName="PerformInsert" Style="position: static"
                                    Visible="<%# RadGrid1.MasterTableView.IsItemInserted %>"><img style="border:0px;vertical-align:middle;" alt="" src="../../../pics/action/Insert.gif" /> 儲存新增資料</asp:LinkButton><asp:LinkButton
                                        ID="LinkButton1" runat="server" CausesValidation="false" CommandName="DeleteSelected"
                                        OnClientClick="javascript:return confirm('Delete all selected Products?')" Style="position: static"><img style="border:0px;vertical-align:middle;" alt="" src="../../../pics/action/Delete.gif" /> 刪除選取資料</asp:LinkButton>
                <asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid" Style="position: static"><img style="border:0px;vertical-align:middle;" alt="" src="../../../pics/action/Refresh.gif" /> 重新整理</asp:LinkButton>
            </CommandItemTemplate>
            <EditFormSettings EditFormType="Template">
                <EditColumn UniqueName="EditCommandColumn1">
                </EditColumn>
                <FormTemplate>
                    <table style="position: static" width="100%">
                        <tr>
                            <td>
                                <table style="position: static">
                                    <tr>
                                        <td>
                                            <span style="color: #ff0000">*</span>類型代碼:</td>
                                        <td>
                                            <telerik:RadTextBox ID="RadTextBox1" runat="server" Style="position: static" Text='<%# Bind("itemtype") %>'
                                                Width="125px">
                                            </telerik:RadTextBox></td>
                                        <td>
                                            <span style="color: #ff0000">*</span>館藏類型:</td>
                                        <td>
                                            <telerik:RadTextBox ID="RadTextBox2" runat="server" Style="position: static" Text='<%# Bind("description") %>'
                                                Width="250px">
                                            </telerik:RadTextBox></td>
                                    </tr>
                                </table>
                                <table style="position: static">
                                    <tr>
                                        <td style="width: 100px">
                                            <span style="color: #ff0000">*</span>館藏類型圖示:</td>
                                    </tr>
                                </table>
                                &nbsp;
                                <table style="position: static">
                                    <tr>
                                        <td>
                                           
                                            <asp:RadioButtonList ID="RadioButtonList1" runat="server" Style="position: static">
                                                <asp:ListItem Selected="True"> </asp:ListItem>
                                                <asp:ListItem> </asp:ListItem>
                                                <asp:ListItem> </asp:ListItem>
                                            </asp:RadioButtonList></td>
                                        <td>
                                            <telerik:RadComboBox ID="RadComboBox1" runat="server"
                                                Skin="Office2007" Style="position: static" DataSourceID="SqlDataSourceimage1" DataTextField="name" DataValueField="url2" Width="250px">
                                                <CollapseAnimation Duration="200" Type="OutQuint" />
                                                <ItemTemplate>
                                                    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("url2") %>' Style="position: static" />
                                                    <asp:Label ID="Label1" runat="server" Style="position: static" Text='<%# Eval("name") %>'></asp:Label>
                                                </ItemTemplate>
                                            </telerik:RadComboBox>
                                            <br />
                                            <br />
                                            <asp:Label ID="Label2" runat="server" Style="position: static" Text="沒有代表圖示"></asp:Label><br />
                                            <br />
                                            <asp:Label ID="Label3" runat="server" Style="position: static" Text="自定代表圖示"></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                            <telerik:RadUpload ID="RadUpload1" runat="server" AllowedFileExtensions=".jpg,.bmp,.gif,.dib,.jpeg,.jpe,.jfif,.png,.tif,.tiff"
                                                ControlObjectsVisibility="None" MaxFileInputsCount="1"
                                                MaxFileSize="1000000" Skin="Vista" Style="position: static" TargetFolder="~/store/UserItemImage">
                                            </telerik:RadUpload>
                                        </td>
                                    </tr>
                                </table>
                                <table style="position: static">
                                    <tr>
                                        <td>
                                            備註:</td>
                                        <td>
                                            <telerik:RadTextBox ID="RadTextBox3" runat="server" Height="50px" Style="position: static"
                                                Text='<%# Bind("summary") %>' TextMode="MultiLine" Width="250px">
                                            </telerik:RadTextBox></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Button ID="btnUpdate" runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update") %>'
                                    Style="position: static" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "儲存新增", "儲存修改") %>' /><asp:Button
                                        ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel" Style="position: static"
                                        Text="放棄編輯" /></td>
                        </tr>
                    </table>
                    <asp:HiddenField ID="createdateHiddenField" runat="server" Value='<%# Bind("createdate") %>' />
                    <asp:HiddenField ID="createnameHiddenField" runat="server" Value='<%# Bind("createname") %>' />
                    <asp:HiddenField ID="storenoHiddenField" runat="server" Value='<%# Bind("storeno") %>' /><asp:HiddenField ID="imageurlHiddenField" runat="server" Value='<%# Bind("imageurl") %>' />
                    <asp:HiddenField ID="imagenameHiddenField" runat="server" Value='<%# Bind("imagename") %>' />
                </FormTemplate>
            </EditFormSettings>
            <PagerStyle Mode="NextPrevNumericAndAdvanced" PagerTextFormat="轉換頁面: {4} &amp;nbsp;現顯示頁面 {0} of {1}, 資料數量 {2} to {3} of {5}."
                Position="TopAndBottom" />
        </MasterTableView>
        <ClientSettings AllowKeyboardNavigation="True" EnableRowHoverStyle="True">
        </ClientSettings>
        <FilterMenu EnableTheming="True" Skin="Sunset">
            <CollapseAnimation Duration="200" Type="OutQuint" />
        </FilterMenu>
    </telerik:RadGrid></telerik:RadAjaxPanel>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LIB1.0ConnectionString %>"
        DeleteCommand="DELETE FROM [parameter_catalog_objectType] WHERE [itemtype] = @itemtype"
        InsertCommand="INSERT INTO [parameter_catalog_objectType] ([itemtype], [description], [imageurl], [imagename], [summary], [createdate], [createname], [storeno]) VALUES (@itemtype, @description, @imageurl, @imagename, @summary, @createdate, @createname, @storeno)"
        SelectCommand="SELECT * FROM [parameter_catalog_objectType]" UpdateCommand="UPDATE [parameter_catalog_objectType] SET [description] = @description, [imageurl] = @imageurl, [imagename] = @imagename, [summary] = @summary, [createdate] = @createdate, [createname] = @createname, [storeno] = @storeno WHERE [itemtype] = @itemtype">
        <DeleteParameters>
            <asp:Parameter Name="itemtype" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="imageurl" Type="String" />
            <asp:Parameter Name="imagename" Type="String" />
            <asp:Parameter Name="summary" Type="String" />
            <asp:Parameter Name="createdate" Type="DateTime" />
            <asp:Parameter Name="createname" Type="String" />
            <asp:Parameter Name="storeno" Type="String" />
            <asp:Parameter Name="itemtype" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="itemtype" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="imageurl" Type="String" />
            <asp:Parameter Name="imagename" Type="String" />
            <asp:Parameter Name="summary" Type="String" />
            <asp:Parameter Name="createdate" Type="DateTime" />
            <asp:Parameter Name="createname" Type="String" />
            <asp:Parameter Name="storeno" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceimage1" runat="server" ConnectionString="<%$ ConnectionStrings:LIB1.0ConnectionString %>"
        SelectCommand="SELECT * FROM [catalog_objectTypeImgUrl]"></asp:SqlDataSource>
            
   
</asp:Content>

here is my code behind 

 Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand
        If e.Item.OwnerTableView.DataSourceID = "SqlDataSource1" Then
            If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then
                Dim uploader As RadUpload = TryCast(e.Item.FindControl("RadUpload1"), RadUpload)
                Dim imageurl As HiddenField = TryCast(e.Item.FindControl("imageurlHiddenField"), HiddenField)
                Dim imagename As HiddenField = TryCast(e.Item.FindControl("imagenameHiddenField"), HiddenField)
                Dim imageFile As UploadedFile = Nothing
                If uploader.UploadedFiles.Count > 0 Then
                    imageFile = uploader.UploadedFiles(0)
                    imageurl.Value = "~/store/UserItemImage/" & imageFile.FileName
                    imagename.Value = imageFile.FileName

                End If
            End If
        End If

    End Sub

Is anyone can tell me why the Radupload is not uploadable in the Radgrid, I have been following the online demo to put the script below:

<telerik:radscriptblock id="RadScriptBlock1" runat="server">
                <script type="text/javascript">
                    //On insert and update buttons click temporarily disables ajax to perform upload actions
                    function conditionalPostback(e, sender)
                    {
                        var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
                  if (sender.EventTarget.match(theRegexp))
                  {
                      var upload = $find(window['UploadId']);
                     
                      //AJAX is disabled only if file is selected for upload
                      if(upload.getFileInputs()[0].value != "")
                      {
                          sender.EnableAjax = false;
                      }
                  }
                    }    
                </script>
            </telerik:radscriptblock>

to disable ajx. Can anyone give me a help please! I found it the uploader is no upload any thing to my target file at all. Thank you

Dorababu
Top achievements
Rank 1
 answered on 13 Aug 2012
0 answers
164 views
                            var executingAssembly = Assembly.GetExecutingAssembly();
//executingAssembly = {App_Web_serversummaryedit.ascx.e5f4f472.hriathhs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null}
                            var webResourceDataArray = NavigationHelper.WebResourceData(webResourceCssPath).Split('|');
                            var webResourceName = webResourceDataArray[webResourceDataArray.Length - 1];
//webResourceName = Telerik.Web.UI.Skins.Grid.css
                            var resourceStream = executingAssembly.GetManifestResourceStream(webResourceName);
                            if (resourceStream != null)
                            {
                                var cssTextStreamReader = new StreamReader(resourceStream);
                                cssText.Append(cssTextStreamReader.ReadToEnd());
                            }

Why this does not work? How to read css from resource file by resource name?? :(

I suspect instead of Assembly.GetExecutingAssembly() must be something like loading Telerik.Web.UI.dll again? Btw, it resides in GAC.
So, how to manage all this?

UPDATE: Done!
var telerikAssembly = Assembly.GetAssembly(typeof(Telerik.Web.SkinRegistrar));
Alexander
Top achievements
Rank 1
 asked on 13 Aug 2012
3 answers
444 views
I've ran into a problem with the RadComboBox that can be simulated on your demo page.
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx 

If the RadComboBox3 (the cities one) has CheckBoxes="true" added to its declaration then, when a normal postback occurs, the list is not repopulated. I can make it repopulate by putting the Page_Load code into the Page_Init event, however this is not suitable as viewstate from other RadComboBox's will not yet have been restored. Code included below.

Markup:

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
<%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
<%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
 
<%@ Page AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.ComboboxExamplesCS.MultipleComboBoxes.DefaultCS"
    Language="c#" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<head runat="server">
    <qsf:HeadTag runat="server" ID="Headtag1"></qsf:HeadTag>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body class="BODY">
    <form runat="server" id="mainForm" method="post">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <qsf:Header runat="server" ID="Header1" NavigationLanguage="C#"></qsf:Header>
        <div id="qsfexWrapper">
            <asp:Label runat="server" AssociatedControlID="RadComboBox1">Continent:</asp:Label>
            <telerik:RadComboBox ID="RadComboBox1"
                runat="server"
                Width="186px"
                CssClass="ComboBox_Continents"
                OnClientSelectedIndexChanging="LoadCountries"
                OnItemsRequested="RadComboBox1_ItemsRequested" />
             
            <asp:Label runat="server" AssociatedControlID="RadComboBox2">Country:</asp:Label>
            <telerik:RadComboBox ID="RadComboBox2"
                runat="server"
                EnableViewState="false"
                Width="186px"
                CssClass="ComboBox_Countries"
                OnClientSelectedIndexChanging="LoadCities"
                OnClientItemsRequested="ItemsLoaded"
                OnItemsRequested="RadComboBox2_ItemsRequested" />
             
            <asp:Label runat="server" AssociatedControlID="RadComboBox3">City:</asp:Label>
            <telerik:RadComboBox ID="RadComboBox3" CheckBoxes="true"
                runat="server"
                EnableViewState="false"
                Width="186px"
                CssClass="ComboBox_Cities"
                OnClientItemsRequested="ItemsLoaded"
                OnItemsRequested="RadComboBox3_ItemsRequested" />
 
            <span class="Button_Submit">
                <telerik:RadButton ID="Button1" runat="server" Text="Explore" OnClick="Button1_Click" />
            </span>
            <asp:Label runat="server" ID="Literal1" CssClass="Label_Result" />
 
        </div>
         
 
        <script type="text/javascript">
//global variables for the countries and cities comboboxes
var countriesCombo;
var citiesCombo;
 
function pageLoad()
{
    // initialize the global variables
    // in this event all client objects
    // are already created and initialized
    countriesCombo = $find("<%= RadComboBox2.ClientID %>");
    citiesCombo = $find("<%= RadComboBox3.ClientID %>");
}
 
function LoadCountries(sender, eventArgs)
{  
    var item = eventArgs.get_item();
    countriesCombo.set_text("Loading...");
    citiesCombo.clearSelection();
     
    // if a continent is selected
    if (item.get_index() > 0)
    {      
        // this will fire the ItemsRequested event of the
        // countries combobox passing the continentID as a parameter
        countriesCombo.requestItems(item.get_value(), false);                              
    }
    else
    {
        // the -Select a continent- item was chosen
        countriesCombo.set_text(" ");
        countriesCombo.clearItems();
         
        citiesCombo.set_text(" ");
        citiesCombo.clearItems();
    }
}
 
function LoadCities(sender, eventArgs)
{  
    var item = eventArgs.get_item();
     
    citiesCombo.set_text("Loading...");
    // this will fire the ItemsRequested event of the
    // cities combobox passing the countryID as a parameter
    citiesCombo.requestItems(item.get_value(), false);                 
}
 
function ItemsLoaded(sender, eventArgs)
{  
    if (sender.get_items().get_count() > 0) {
        // pre-select the first item
        sender.set_text(sender.get_items().getItem(0).get_text());
        sender.get_items().getItem(0).highlight();
    }
 
    sender.showDropDown();
}
        </script>
 
        <qsf:Footer runat="server" ID="Footer1"></qsf:Footer>
    </form>
</body>
</html>

Code:
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using Telerik.Web.UI;
 
namespace Telerik.ComboboxExamplesCS.MultipleComboBoxes
{
    public partial class DefaultCS: System.Web.UI.Page
    {
        private const string MessageTemplate = "You chose to explore the city of {0} in {1}, {2}";
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                // Fill the continents combo.
                LoadContinents();
            else if (!Page.IsCallback)
            {
                // On regular postbacks restore the items of the related ComboBoxes.
                // Their selected items will be automatically restored from their ClientState.
                LoadCountries(RadComboBox1.SelectedValue);
                LoadCities(RadComboBox2.SelectedValue);
            }
        }
 
        protected void LoadContinents()
        {
            SqlConnection connection = new SqlConnection(
            ConfigurationManager.ConnectionStrings["TelerikConnectionString"].ConnectionString);
 
            SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Continents ORDER By Name", connection);
            DataTable dt = new DataTable();
            adapter.Fill(dt);                       
 
            RadComboBox1.DataTextField = "Name";
            RadComboBox1.DataValueField = "ID";
            RadComboBox1.DataSource = dt;
            RadComboBox1.DataBind();
            // Insert the first item.
            RadComboBox1.Items.Insert(0, new RadComboBoxItem("- Select a continent -"));           
        }
 
        protected void LoadCountries(string continentID)
        {
            SqlConnection connection = new SqlConnection(
            ConfigurationManager.ConnectionStrings["TelerikConnectionString"].ConnectionString);
 
            // Select a country based on the continentID.
            SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Countries WHERE ContinentID=@ContinentID ORDER By Name", connection);
            adapter.SelectCommand.Parameters.AddWithValue("@ContinentID", continentID);
 
            DataTable dt = new DataTable();
            adapter.Fill(dt);
 
            RadComboBox2.DataTextField = "Name";
            RadComboBox2.DataValueField = "ID";
            RadComboBox2.DataSource = dt;
            RadComboBox2.DataBind();
        }
 
        protected void LoadCities(string countryID)
        {
            SqlConnection connection = new SqlConnection(
            ConfigurationManager.ConnectionStrings["TelerikConnectionString"].ConnectionString);
 
            // Select a city based on the countryID.
            SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Cities WHERE CountryID=@CountryID ORDER By Name", connection);
            adapter.SelectCommand.Parameters.AddWithValue("@CountryID", countryID);
 
            DataTable dt = new DataTable();
            adapter.Fill(dt);
 
            RadComboBox3.DataTextField = "Name";
            RadComboBox3.DataValueField = "ID";
            RadComboBox3.DataSource = dt;
            RadComboBox3.DataBind();
        }
 
        protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            LoadContinents();
        }
 
        protected void RadComboBox2_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            // e.Text is the first parameter of the requestItems method
            // invoked in LoadCountries method
            LoadCountries(e.Text);
        }
 
        protected void RadComboBox3_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            // e.Text is the first parameter of the requestItems method
            // invoked in LoadCities method
            LoadCities(e.Text);
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            Literal1.Text = string.Empty;
 
            if (RadComboBox1.SelectedIndex > 0)
                Literal1.Text = string.Format(MessageTemplate, RadComboBox3.Text, RadComboBox2.Text, RadComboBox1.Text);
        }
    }
}
Nencho
Telerik team
 answered on 13 Aug 2012
11 answers
753 views
My requirement is Can we show scanned PDF using this viewer in ASP.net page? Also I will like to know do we have any any telerik control from where user can see pdf files in ASP.net page in Telerik Grid ? Kindly suggest.
Subhashchandra
Top achievements
Rank 1
 answered on 13 Aug 2012
3 answers
87 views
Hello,

I have Explorer.aspx that defines a RadWindowManager as seen below:

<telerik:RadWindowManager ID="radWinMgr" runat="server" AutoSize="true" EnableShadow="true" ReloadOnShow="true" ShowContentDuringLoad="false" VisibleStatusbar="false"  OnClientClose="fncClientClose">
    <Windows>
        <telerik:RadWindow ID="rwUploadParent" runat="server" Behaviors="Close" NavigateUrl="Upload.aspx"></telerik:RadWindow>
        <telerik:RadWindow ID="rwDownloadParent" runat="server" Behaviors="Close" NavigateUrl="Download.aspx"></telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>

 

The OnClientClose function that you see referenced above is defined as follows:

<script type="text/javascript">
    function fncClientClose(winNewRep, args) {
        var arg = args.get_argument();
 
        if (arg == 1) {
            //Refresh file explorer:
            var oExplorer = $find("<%=radExplorer.ClientID%>");
            var dirPath = oExplorer.get_currentDirectory();
 
            if (dirPath) oAjaxPanel.ajaxRequest(dirPath);
        }
    }
</script>

 

The purpose of the function is to refresh the RadFileExplorer, but this function never gets called. I have a button click the opens Upload.aspx as a RadWindow as follows:

<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClientClick="fncOpenPopupWin('UploadMgr.aspx?UpFolder=', 'rwUploadParent'); return false;" />

 

As you see the OnClientClick of the button calls another function and passes the page name to open, including a query string parameter, and the name of the RadWindow:

<script type="text/javascript">
    function fncOpenPopupWin2(strPage, strParent) {
        var varLocation = "/Root";
        var winNewRep = radopen(strPage + varLocation, strParent);
    }
</script>

 

When the button is clicked, page Upload.aspx opens, the user does what he/she wants, and then closes Upload.aspx. At that point, I expect the OnClientClose of the RadWindownManager to execute, but it never does.

I have read many postings about this kind of problem here on the forum, but none of the solutions have helped my situation. I appreciate any time someone takes to review this and offer suggestions.

 

Thank you,

Steven

Marin Bratanov
Telerik team
 answered on 13 Aug 2012
1 answer
129 views
The title bar has transparency, an show as inactive windows.
I tried to create css like this:


    
         
.RadWindow table .rwTitlebar, .RadWindow table .rwTopLeft, .RadWindow table .rwTopRight, .RadWindow table .rwFooterLeft, .RadWindow table .rwFooterRight, .RadWindow table .rwFooterCenter, .RadWindow table .rwBodyLeft, .RadWindow table .rwBodyRight
{
    filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100) !important;
    opacity: 1 !important;
}
          
.RadWindow.rwShadow table.rwShadow .rwTitlebar, .RadWindow.rwShadow table.rwShadow .rwTopLeft, .RadWindow.rwShadow table.rwShadow .rwTopRight, .RadWindow.rwShadow table.rwShadow .rwFooterLeft, .RadWindow.rwShadow table.rwShadow .rwFooterRight, .RadWindow.rwShadow table.rwShadow .rwFooterCenter, .RadWindow.rwShadow table.rwShadow .rwBodyLeft, .RadWindow.rwShadow table.rwShadow .rwBodyRight
{
    filter: none !important;
}   

But didn't work.

How I can fix this issue?
Marin Bratanov
Telerik team
 answered on 13 Aug 2012
4 answers
1.1K+ views
Hi,
I am using Telerik controls version "2009.3.1103.20", visual studio 2008 and website project.
Now on one of my page, I have RadGrid and have "DetailTable" underneath "MasterTableView", so basically when I assign datasource to my master table, it displays option to "Expand\Collapse" and when I click on "Expand" arrow, it fires "OnDetailTableDataBind" event where I assign dataset to my detail table and it displays whatever number of rows I have in detail table.
So basically I have kind of master-detail view where I can expand\collapse items to view detail view.

Now on my "DetailTable", I have some rows which has some buttons and on click of those buttons, I am updating some values in my database and refreshing grid. The problem is that while binding grid again, grid is losing its state of already expanded rows and all the rows are in "Collapsed" state. What I want is after rebinding grid, it should keep expanded rows as it is. This is happening on postback always. Even If I use "Sorting" on my master table fields, it collapses all the rows but I want to show the expanded rows as it is whichever were expanded already by user, should stay expanded after postback.

Any suggestion how to achieve this?
Here is my RadGrid.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" AllowSorting="true"
    AutoGenerateColumns="False" GridLines="Both" OnNeedDataSource="RadGrid1_needdatasource"
    OnItemDataBound="RadGrid1_ItemDataBound" OnDetailTableDataBind="RadGrid1_DetailTableDataBind"
    OnItemCreated="RadGrid1_ItemCreated" AllowMultiRowSelection="true"
    AllowFilteringByColumn="true" OnItemCommand="RadGrid1_ItemCommand"
      
                                              
    SelectedItemStyle-CssClass="SelectedItem" Skin="Default">
    <PagerStyle Mode="NextPrevNumericAndAdvanced" Position="TopAndBottom" AlwaysVisible="true" />
    <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
        <Selecting AllowRowSelect="true" />
    </ClientSettings>
    <FooterStyle BackColor="LightBlue" />
    <MasterTableView ShowHeadersWhenNoRecords="true" AllowFilteringByColumn="true" DataKeyNames="RequestInfoID"
        Name="ApprovalsMaster">
        <DetailTables>
            <telerik:GridTableView DataKeyNames="RequestInfoID" Width="80%" Name="ApprovalsDetail"
                AllowPaging="false" runat="server">
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="RequestInfoID" MasterKeyField="RequestInfoID" />
                </ParentTableRelation>
                <Columns>
                    <telerik:GridBoundColumn SortExpression="ApprovalLevelID" HeaderText="ApprovalLevelID"
                        HeaderButtonType="TextButton" DataField="ApprovalLevelID" UniqueName="ApprovalLevelID">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Approve" UniqueName="ApproveRequest" AllowFiltering="false">
                        <ItemTemplate>
                            <asp:Button runat="server" ID="btnApproveRequest" Text="Approve" CssClass="ButtonCSS"
                                ToolTip="Click here to Approve Request" CausesValidation="False" OnClick="btnApproveRequest_Click"
                                OnClientClick="javascript:var agree= confirm('Are you sure you want to approve this Request? '); if(agree){ Page_BlockSubmit = false;buttonClicked_WithObj(this); return true; };else {return false;};"
                                CommandArgument='<%# 
                            Eval ( "RequestInfoID").ToString() 
                            + ";" +
                            Eval ( "ApprovalLevelID").ToString() 
                              
                            %>' />
                              
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </telerik:GridTableView>
        </DetailTables>
        <Columns>
            <telerik:GridNumericColumn DataField="RequestInfoID" HeaderText="Request No." SortExpression="RequestInfoID"
                DataType="System.Int64" FilterControlWidth="40px">
            </telerik:GridNumericColumn>
            <telerik:GridBoundColumn DataField="DepartmentName" HeaderText="Department" SortExpression="DepartmentName"
                UniqueName="DepartmentName">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings>
            <PopUpSettings ScrollBars="None" />
        </EditFormSettings>
        <ExpandCollapseColumn Resizable="False" Visible="False">
            <HeaderStyle />
        </ExpandCollapseColumn>
        <RowIndicatorColumn Visible="False">
            <HeaderStyle />
        </RowIndicatorColumn>
    </MasterTableView>
</telerik:RadGrid>

Here is what I tried to expand it back after postback but could not get it working, not sure why. Just pasting for reference which I tried. Please do let me know the best option to achieve this.
OnDataBound="RadGrid1_DataBound"
OnDataBinding="RadGrid1_DataBinding"                                  
  
    protected void RadGrid1_DataBound(object sender, EventArgs e)
    {
        LoadGroupsExpandedState(RadGrid1);
    }
  
    protected void RadGrid1_DataBinding(object sender, EventArgs e)
    {
        SaveGroupsExpandedState(RadGrid1);
    }  
  
    private void SaveGroupsExpandedState(RadGrid grid)
    {
  
        GridItem[] groupItems = grid.MasterTableView.GetItems(GridItemType.GroupHeader);
        if (groupItems.Length > 0)
        {
            List<string> collapsedIndexes = new List<string>();
            foreach (GridItem item in groupItems)
            {
                if (!item.Expanded)
                {
                    GridGroupHeaderItem groupHeader = (GridGroupHeaderItem)item;
                    collapsedIndexes.Add(groupHeader.DataCell.Text);
                }
            }
  
            Session["groupExpandedState"] = collapsedIndexes;
        }
    }
  
    private void LoadGroupsExpandedState(RadGrid grid)
    {
        List<string> collapsedIndexes = Session["groupExpandedState"] as List<string>;
        if (collapsedIndexes != null)
        {
            foreach (GridItem item in grid.MasterTableView.GetItems(GridItemType.GroupHeader))
            {
                GridGroupHeaderItem groupHeader = (GridGroupHeaderItem)item;
                if (collapsedIndexes.Contains(groupHeader.DataCell.Text))
                {
                    item.Expanded = false;
                }
            }
        }
    }

Thanks in advance,



Sam
Top achievements
Rank 1
 answered on 13 Aug 2012
8 answers
374 views
I saw this older thread http://www.telerik.com/community/forums/aspnet-ajax/image-editor/imageurl-http.aspx and it's conclusion is that you can not use the ImageUrl unless it is localized inside a folder that the application has access to.

Has this since been changed? This is quite an inconvenience as most of the images I will be using are hosted on a separate media server.

I'm getting my URL off of a data table, which has all of the images already loaded.

public DataTable ProductDetailsDataTable
{
    get
    {
        return _productDetailsDataTable;
    }
 
    set
    {
        _productDetailsDataTable = value;
 
        //add code to read data from table and do something with it
        DataRow dr = _productDetailsDataTable.Rows[0];
 
        RadImageEditor1.ImageUrl = dr["Image1Url"].ToString();
         
 
    }
}
Niko
Telerik team
 answered on 13 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?