Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
115 views
I was using asp update panel before but because of some problems with telerik components i changed update panel with rad ajax panel... now i have troble with client side validators

they are not working correctly..please someone help...how will i validate my page client-side...i've tried many senerios...but nothing worked..

i saw web service validation but how can i apply this to any control..demo is not clear????
Pako
Top achievements
Rank 1
 answered on 25 Mar 2011
2 answers
78 views
Hello,

I have a requirement that needs comboboxes in the tabs(instead of Text) and I need to display the data  as per the selection on that particular tab, I don't know if it is feasible, I was planning on using Ajax controls for this page, I am just wondring if the tab strip supports it, if not what are the alternatives.

I am adding a screenshot that would give you a rough idea on the requirements. Your input is greatly appriciated.

Thanks,
SC
Srujana
Top achievements
Rank 1
 answered on 25 Mar 2011
9 answers
215 views
I'm having trouble implementing a solution similar to the example from the second grid on the following page to do a "between" filter on a date column in a RadGrid.

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx

As far as I can tell I have implemented all the relevant stuff from the example and the only difference is I'm using an EntityDataSource instead of a SqlDataSource.  However, when I select a date from either box I get the following error.

The datetime literal value '2010-06-02' is not valid. Near line 6, column 17.

 

I used the small example below to reproduce the error.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
</head> 
<body> 
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    <div> 
        <telerik:RadGrid ID="gvWorkItem" runat="server" AutoGenerateColumns="False" DataSourceID="edsWorkItem"   
            GridLines="None" AllowFilteringByColumn="True">  
            <MasterTableView DataKeyNames="WorkItemID" DataSourceID="edsWorkItem">  
                <Columns> 
                    <telerik:GridBoundColumn DataField="WorkItemID" DataType="System.Int32" HeaderText="#"   
                        ReadOnly="True" SortExpression="WorkItemID" UniqueName="WorkItemID" /> 
                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description"   
                        SortExpression="Description" UniqueName="Description" /> 
                    <telerik:GridBoundColumn DataField="DueDate" DataType="System.DateTime"   
                        HeaderText="Due Date" SortExpression="DueDate" UniqueName="DueDate">  
                        <FilterTemplate> 
                            <telerik:RadDatePicker ID="FromDatePicker" runat="server"   
                                ClientEvents-OnDateSelected="FromDatePicker_DateSelected" /><br /> 
                            <telerik:RadDatePicker ID="ToDatePicker" runat="server"   
                                ClientEvents-OnDateSelected="ToDatePicker_DateSelected" /> 
                            <telerik:RadScriptBlock ID="RadCodeBlock1" runat="server">  
                                <script type="text/javascript">  
                                    function FromDatePicker_DateSelected(sender, args) {  
                                        var tableView =   
                                            $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");  
                                        var ToPicker =   
                                            $find('<%# ((GridItem)Container).FindControl("ToDatePicker").ClientID %>');  
                                        var fromDate = FormatSelectedDate(sender);  
                                        var toDate = FormatSelectedDate(ToPicker);  
                                        tableView.filter("DueDate", fromDate + " " + toDate, "Between");  
                                    }  
                                    function ToDatePicker_DateSelected(sender, args) {  
                                        var tableView =   
                                            $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");  
                                        var FromPicker =   
                                            $find('<%# ((GridItem)Container).FindControl("FromDatePicker").ClientID %>');  
                                        var fromDate = FormatSelectedDate(FromPicker);  
                                        var toDate = FormatSelectedDate(sender);  
                                        tableView.filter("DueDate", fromDate + " " + toDate, "Between");  
                                    }  
                                    function FormatSelectedDate(picker) {  
                                        var date = picker.get_selectedDate();  
                                        var dateInput = picker.get_dateInput();  
                                        var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date,   
                                            dateInput.get_displayDateFormat());  
                                        return formattedDate;  
                                    }  
                                </script> 
                            </telerik:RadScriptBlock> 
                        </FilterTemplate> 
                    </telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
        <asp:EntityDataSource ID="edsWorkItem" runat="server" ConnectionString="name=WorkDataEntities"   
            DefaultContainerName="WorkDataEntities" EntitySetName="WorkItems" /> 
    </div> 
    </form> 
</body> 
</html> 
Radoslav
Telerik team
 answered on 25 Mar 2011
4 answers
103 views
Hi All,

I am using RadControls for ASP.NET Q3 2010. I have a radgrid which has filtering enabled. When toggling the filter button on for the first time, the text "select" is temporarily displayed where the filter control should be. The text is displayed for a moment then the filter controls are rendered correctly. See attachment. I am not sure what would cause this behavior.

How do I prevent "select" from being displayed at all when the filter controls are being rendered?

Regards,
Cliff
Radoslav
Telerik team
 answered on 25 Mar 2011
1 answer
63 views
Hi, 
I have used RadDockZone to perform drag and drop. The Drag and Drop works fine. But the problem is i couldn't save or maintain the order in which the final drag and drop leaves.
i.e if initially, the order is as 

Item A - dock[0]
Item B - dock[1]
Item C - dock[2]
Item D - dock[3]
After several drag and drop, the order is changed as
Item C - dock[2]
Item D - dock[3]
Item B - dock[1]
Item A - dock[0]

I couldn't save the position that 'Item C' is now in 1st position, 'Item D' in 2nd position...etc of the order.
Is there any way to save the actual position i.e the order ?


Pero
Telerik team
 answered on 25 Mar 2011
2 answers
315 views
Hi,

I have radgrid and "inPlace" edit mode. whenever i want to edit save and cancel display left side automatically. but i want to display right side in these two button. Please let me know how do we display in right side.

I have attached image also. please check and give me a tips for this one,

Thanks in Advance,
Dhamu.
Dhamodharan
Top achievements
Rank 1
 answered on 25 Mar 2011
2 answers
142 views
Good afternoon,

I am working on an application that sends a message with one ore more file attached to it. I'm using a AsyncUpload control to accomplish the upload of the files while user can still be writting the message.

The problem is that, when deploying it, the following happens:
1. User chooses a file to upload: it begins uploading (progress bar starts moving and left icon remains orange)
2. After finishing upload, suddenly an exception is thrown. Exception can be one of these:
a) The proccess cannot access the file XXXXXX.doc because it is in use by other process: this only happens with small (200kb or less) files. Temporal file does not appear in the Temporary Filder.
b) Remote server said: NotFound: this happens with big files (9 MB more or less in our tests). In this case, we already find the file in the Temporary Folder. The fact is that the file there is ok. After changing its extension to ZIP (which was the file's extension), it works fine, so the file is correctly upload, but it stills throws an exception.

I've tried changing the security settings of the temporary folders, giving permissions to users, but nothing changes.

The curious thing is that this only happens in deplyment. Control works fine in local machine.

Do you have any idea about what I've done wrong?
Equipo Desarrollo
Top achievements
Rank 1
 answered on 25 Mar 2011
10 answers
170 views
All My RadGrid event SelectedIndexChanged don't work after 2010.2.826! Anybody can help me?
gezim
Top achievements
Rank 1
 answered on 25 Mar 2011
3 answers
160 views
Hi,

I was trying to RadListBox LoadOnDemand feature. I was creating the RadListBox and setting EnableLoadOnDemand property dynamically/programatically. I gave it a DataSource and called DataBind on it. But, It loads all the data in it instead of doing the LoadOnDemand. Am i missing something?

Thanks in advance!!!
Helen
Telerik team
 answered on 25 Mar 2011
1 answer
96 views

I have a series of stored procedures created to handle the Select, Insert, Update and Delete needs of the system. Many of the columns are dynamically driven.  The delete functionality works perfectly but Update is throwing me some odd issues and I'm not certain where I've made my mistakes. Any direction would be helpful.

The Problem:
When you click Edit the form comes up correctly (See awardgrid-edit.jpg) with even the ItemID on the top indicating I have the appropriate record correlating to the database ID.  However when you click the Update button the AJAX does a post back and the Edit field is empty and the button for the [Update] now has no text (See awardgrid-afterupdate.jpg).

The ASPX Page Snippet

<telerik:radscriptmanager ID="RadScriptManager1" Runat="server">
</telerik:radscriptmanager>
<uc1:Awards ID="Awards1" runat="server" />

Awards User Control Snippet (ASCX)
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="rgProfileItem">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="rgProfileItem" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Skin="Windows7" EnableSkinTransparency="true" runat="server" />
  
<telerik:RadGrid ID="rgProfileItem" runat="server" 
    AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" 
    GridLines="None" Skin="Windows7"
    OnItemDataBound="rgProfileItem_ItemDataBound" OnInsertCommand="rgProfileItem_InsertCommand"
    OnDeleteCommand="rgProfileItem_DeleteCommand" OnUpdateCommand="rgProfileItem_UpdateCommand" 
    onneeddatasource="rgProfileItem_NeedDataSource" AllowAutomaticUpdates="false" AllowAutomaticInserts="false">
  
<MasterTableView AutoGenerateColumns="False" AllowAutomaticInserts="false" AllowAutomaticUpdates="false"
 DataKeyNames="ItemID" EditMode="EditForms">
  
    <Columns>
        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="Edit">
            <HeaderStyle Width="20px" />
        </telerik:GridEditCommandColumn>
        <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" 
            ImageUrl="~/images/delete-16x16.png" Text="Delete" UniqueName="Delete">
            <HeaderStyle Width="20px" />
        </telerik:GridButtonColumn>
        <telerik:GridBoundColumn DataField="Title" 
            FilterControlAltText="Filter Title column" HeaderText="Title" 
            SortExpression="Title" UniqueName="Title">
            <HeaderStyle Width="30%" />
        </telerik:GridBoundColumn>
        <telerik:GridDateTimeColumn DataField="DateReceived" 
            FilterControlAltText="Filter DateReceived column" HeaderText="Date Received" 
            SortExpression="DateReceived" UniqueName="DateReceived" 
            DataType="System.DateTime">
            <HeaderStyle Width="150px" />
        </telerik:GridDateTimeColumn>
        <telerik:GridTemplateColumn DataField="Notes" 
            FilterControlAltText="Filter Notes column" Groupable="False" HeaderText="Notes" 
            UniqueName="Notes">
            <ItemTemplate>
                <asp:Label ID="shortNote" runat="server" Text='<%# Eval("Notes") %>' />
                <asp:Label ID="longNote" runat="server" Visible="false" Text='<%# Eval("Notes") %>' />
                <telerik:RadToolTip ID="RadToolTip1" runat="server" 
                    Skin="Windows7" RelativeTo="Element" Width="400px" CssClass="infotooltip" Position="TopCenter" TargetControlID="shortNote">
                    <%# Eval("Notes") %>
                </telerik:RadToolTip>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>
<EditFormSettings InsertCaption="Add new item" CaptionFormatString="Edit Item: {0}"
    CaptionDataField="ItemID" EditFormType="Template" PopUpSettings-Modal="true" PopUpSettings-Width="600px">
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
    <FormTemplate>
        <asp:Table ID="pubForm" CssClass="pubForm" CellSpacing="0" CellPadding="2" runat="server">
            <asp:TableFooterRow>
                <asp:TableCell ColumnSpan="2">
                    <asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                    </asp:Button
                    <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">
                    </asp:Button>
                </asp:TableCell>
            </asp:TableFooterRow>
        </asp:Table
    </FormTemplate>
  
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False"></FilterMenu>
  
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
  
</telerik:RadGrid>

Awards User Control Code Behind (ASCX.CS)
int maxFieldLength = 100;
    int itemTypeID = 2; //ID item for Awards/Honors
    SqlConnection cn = new SqlConnection(CONNSTRINGINFO);
    protected void Page_Load(object sender, EventArgs e)
    {
    }
  
    protected void rgProfileItem_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand("sp_getProfileItem", cn);
        adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
        adapter.SelectCommand.Parameters.AddWithValue("@ProfileItemTypeId", itemTypeID);
        if (!string.IsNullOrEmpty(Request.QueryString["uid"]))
        {
            adapter.SelectCommand.Parameters.AddWithValue("@PersonID", Request.QueryString["uid"]);
        }
        DataTable myDataTable = new DataTable();
        cn.Open();
        try
        {
            adapter.Fill(myDataTable);
        }
        finally
        {
            cn.Close();
        }
        rgProfileItem.DataSource = myDataTable;
    }
    protected void rgProfileItem_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
        {
            Label target = (Label)e.Item.FindControl("shortNote");
            if (!Object.Equals(target, null))
            {
                if (target.Text.Length > maxFieldLength)
                {
                    target.Text = target.Text.Substring(0, maxFieldLength) + " ...";
                }
            }
        }
        if (e.Item is GridEditFormItem && (e.Item as GridEditableItem).IsInEditMode)
        {
            GridEditableItem editedItem = (GridEditableItem)e.Item;
            string ItemID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ItemID"].ToString();
            Table editFormTable = (Table)editedItem.FindControl("pubForm");
            LoadProfileFields(int.Parse(ItemID), editFormTable);
        }
  
    }
  
    protected void rgProfileItem_DeleteCommand(object sender, GridCommandEventArgs e)
    {
        //Delete Function
        cn.Open();
        GridDataItem item = (GridDataItem)e.Item;
        try
        {
            SqlCommand comm = new SqlCommand("sp_deleteProfileItem", cn);
            comm.CommandType = CommandType.StoredProcedure;
            comm.Parameters.AddWithValue("@ItemID", item.GetDataKeyValue("ItemID"));
            comm.ExecuteNonQuery();
            comm.Dispose();
        }
        catch (Exception ex)
        {
            lblErrMsg.Text = "<br />" + ex.Message;
        }
        finally
        {
            //lblErrMsg.Text = "Deleted " + item.GetDataKeyValue("ItemID");;
            cn.Close();
        }
    }
  
    protected void rgProfileItem_UpdateCommand(object sender, GridCommandEventArgs e)
    {
  
        DataTable dtProfileInfo = new DataTable();
        //Get the GridEditableItem of the RadGrid
        GridEditableItem editedItem = e.Item as GridEditableItem;
        string ItemID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ItemID"].ToString();
  
        cn.Open();
        try
        {
            string profInfo = ""; //A placeholder for the dynamic fields Profile Information uses
            string strProcName = "sp_updateProfileItem";
  
            //Get the DataTable of all Publication Fields
            dtProfileInfo = getProfileInfoFields();
            foreach (DataRow dr in dtProfileInfo.Rows)
            {
                //It is important to note that the stored procedure is expecting all rows to be seperated by a | and fields seperated by a =.
                //These symbols were used because they are not 'common place' and should not throw erroneous data.
                profInfo += dr["FieldID"] + "=" + getDynamicField(stripText(dr["FieldName"].ToString())) + "|";
            }
            if (profInfo.Length > 0)
            {
                profInfo = profInfo.Substring(0, profInfo.Length - 1); //Remove the last | symbol
            }
  
            SqlCommand comm = new SqlCommand(strProcName, cn);
            comm.CommandType = CommandType.StoredProcedure;
            comm.Parameters.AddWithValue("@ItemType", itemTypeID);  //Item Type ID
            comm.Parameters.AddWithValue("@ItemInfo", profInfo); //String of dynamic field values
            comm.Parameters.AddWithValue("@ProfileItem", ItemID);    //ItemID
            comm.ExecuteNonQuery();
            rgProfileItem.Rebind();
            editedItem.Edit = false;
        }
        catch (Exception ex)
        {
            rgProfileItem.Controls.Add(new LiteralControl("Unable to update Item. Reason: " + ex.Message));
            e.Canceled = true;
        }
        finally
        {
            cn.Close();
        }
  
    }
  
    protected void rgProfileItem_InsertCommand(object source, GridCommandEventArgs e)
    {
    }
  
    private void LoadProfileFields(int ItemID,Table formTable)
    {
        //Based on the Profile Item Type, determine and add what fields are neccessary.
        SqlCommand comm = new SqlCommand("sp_getProfileItemFieldsByType", cn);
        comm.CommandType = CommandType.StoredProcedure;
        comm.Parameters.AddWithValue("@ItemTypeID", itemTypeID);
        string tmpFieldValue = "";
        int rowInsertAt = formTable.Rows.Count - 1;
  
        if (ItemID != null && ItemID > 0)
        {
            comm.Parameters.Add("@ItemID", ItemID);
        }
        SqlDataAdapter fieldTypeAdapter = new SqlDataAdapter(comm);
  
        DataTable fieldTypeDataTable = new DataTable();
        fieldTypeAdapter.Fill(fieldTypeDataTable);
  
        foreach (DataRow fieldTypeDataRow in fieldTypeDataTable.Rows)
        {
            tmpFieldValue = "";
            try
            {
                bool isRequired = false;
                if (fieldTypeDataRow["Required"].ToString().Trim().ToLower() == "true")
                {
                    isRequired = true;
                }
                tmpFieldValue = fieldTypeDataRow["FieldValue"].ToString();
                rowInsertAt = formTable.Rows.Count - 1;
  
                switch (fieldTypeDataRow["FieldType"].ToString())
                {
                    case "Date":
                        formTable.Rows.AddAt(rowInsertAt,AddRow_Datebox(fieldTypeDataRow["FieldName"].ToString(), tmpFieldValue, isRequired));
                        break;
                    case "Textarea":
                        formTable.Rows.AddAt(rowInsertAt, AddRow_Textarea(fieldTypeDataRow["FieldName"].ToString(), tmpFieldValue, isRequired));
                        break;
                    default:
                        //By Default everything is a single-line text box.
                        formTable.Rows.AddAt(rowInsertAt,AddRow_Textbox(fieldTypeDataRow["FieldName"].ToString(), tmpFieldValue, isRequired));
                        break;
                }
            }
            catch
            {
                lblErrMsg.Text += "Field Broke!!<br>";
            }
        }
  
    }
  
    private DataTable getProfileInfoFields()
    {
        SqlCommand comm = new SqlCommand("sp_getProfileItemFieldsByType", cn);
        comm.CommandType = CommandType.StoredProcedure;
  
        if (itemTypeID > 0)
        {
            comm.Parameters.Add("@ItemTypeID", itemTypeID);
        }
        else
        {
            return null;
        }
        SqlDataAdapter adapter = new SqlDataAdapter(comm);
  
        DataTable dataTable = new DataTable();
        adapter.Fill(dataTable);
        return dataTable;
    }
  
    private TableRow AddRow_Textbox(string rowField, string defaultValue, bool isRequired)
    {
        TableRow tr = new TableRow();
        TableCell tcLabel = new TableCell();
        TableCell tcField = new TableCell();
  
        tcLabel.CssClass = "label";
        tcLabel.Text = rowField;
  
        RadTextBox rtb = new RadTextBox();
        rtb.Skin = "Windows7";
        rtb.Width = 230;
        rtb.ID = stripText(rowField);
        rtb.Text = defaultValue.Trim();
        tcField.Controls.Add(rtb);
        if (isRequired)
        {
            RequiredFieldValidator rfv = new RequiredFieldValidator();
            rfv.ControlToValidate = rtb.ID;
            rfv.ErrorMessage = "You must fill out this field";
            rfv.CssClass = "validator";
            rfv.ValidationGroup = "PublicationFields";
            tcField.Controls.Add(rfv);
            tcLabel.Text += "<span class=\"required-field\">*</span>";
        }
  
        tr.Cells.Add(tcLabel);
        tr.Cells.Add(tcField);
  
        //int rowInsertAt = pubForm.Rows.Count - 1;
        //pubForm.Rows.AddAt(rowInsertAt, tr);
        return tr;
    }
  
    private TableRow AddRow_Datebox(string rowField, string defaultValue, bool isRequired)
    {
        TableRow tr = new TableRow();
        TableCell tcLabel = new TableCell();
        TableCell tcField = new TableCell();
        DateTime dr;
  
        tcLabel.CssClass = "label";
        tcLabel.Text = rowField;
  
        RadDateInput rdi = new RadDateInput();
        rdi.DateFormat = "d";
        rdi.Skin = "Windows7";
        rdi.Width = 230;
        rdi.ID = stripText(rowField);
        if (DateTime.TryParse(defaultValue, out dr))
        {
            rdi.SelectedDate = dr;
        }
        tcField.Controls.Add(rdi);
        if (isRequired)
        {
            RequiredFieldValidator rfv = new RequiredFieldValidator();
            rfv.ControlToValidate = rdi.ID;
            rfv.ErrorMessage = "You must fill out this field";
            rfv.Display = ValidatorDisplay.Dynamic;
            rfv.CssClass = "validator";
            rfv.ValidationGroup = "PublicationFields";
            tcField.Controls.Add(rfv);
            tcLabel.Text += "<span class=\"required-field\">*</span>";
        }
  
        tr.Cells.Add(tcLabel);
        tr.Cells.Add(tcField);
  
        //int rowInsertAt = pubForm.Rows.Count - 1;
        //pubForm.Rows.AddAt(rowInsertAt, tr);
        return tr;
    }
  
    private TableRow AddRow_Textarea(string rowField, string defaultValue, bool isRequired)
    {
        TableRow tr = new TableRow();
        TableCell tcLabel = new TableCell();
        TableCell tcField = new TableCell();
  
        tcLabel.CssClass = "label";
        tcLabel.Text = rowField;
  
        RadEditor rtb = new RadEditor();
  
        rtb.Skin = "Windows7";
        rtb.ToolbarMode = EditorToolbarMode.ShowOnFocus;
        rtb.SkinID = "DefaultSetOfTools";
        rtb.ToolsFile = "~/App_Data/ToolsFile.xml";
        rtb.Width = 500;
        rtb.Height = 200;
          
        string[] imagePath = {"~/Editor/Img/UserDir/Marketing,~/Editor/Img/UserDir/PublicRelations"};
        rtb.ImageManager.ViewPaths = imagePath;
        rtb.ImageManager.UploadPaths = imagePath;
        rtb.ID = stripText(rowField);
        rtb.Content = defaultValue;
        tcField.CssClass = "field_onTop";
        tcField.Controls.Add(rtb);
        if (isRequired)
        {
            RequiredFieldValidator rfv = new RequiredFieldValidator();
            rfv.ControlToValidate = rtb.ID;
            rfv.ErrorMessage = "You must fill out this field";
            rfv.CssClass = "validator";
            rfv.ValidationGroup = "ProfileFields";
            tcField.Controls.Add(rfv);
            tcLabel.Text += "<span class=\"required-field\">*</span>";
        }
  
        tr.Cells.Add(tcLabel);
        tr.Cells.Add(tcField);
  
        //int rowInsertAt = pubForm.Rows.Count - 1;
        //pubForm.Rows.AddAt(rowInsertAt, tr);
        return tr;
    }
  
    private string stripText(string toStrip)
    {
        string pattern = "[^\\w\\.@-]";
        Regex rgx = new Regex(pattern);
        return rgx.Replace(toStrip, "");
    }
  
    private Control FindControlRecursive(Control root, string id)
    {
        if (root.ID == id)
        {
            return root;
        }
  
        foreach (Control c in root.Controls)
        {
            Control t = FindControlRecursive(c, id);
            if (t != null)
            {
                return t;
            }
        }
  
        return null;
    }
    private string getDynamicField(string controlID)
    {
        string fieldValue = "";
        Control fieldControl = FindControlRecursive(Page, controlID);
        if (fieldControl != null)
        {
            string tmpTypeBox = fieldControl.GetType().Name;
            switch (tmpTypeBox)
            {
                case "RadTextBox":
                    RadTextBox tmpTextControl = (RadTextBox)fieldControl;
                    fieldValue = tmpTextControl.Text;
                    break;
                case "RadDateInput":
                    RadDateInput tmpDateControl = (RadDateInput)fieldControl;
                    if (tmpDateControl.SelectedDate.HasValue)
                    {
                        fieldValue = tmpDateControl.DbSelectedDate.ToString().Split(' ')[0];
                    }
                    else
                    {
                        fieldValue = "";
                    }
                    break;
            }
        }
        else
        {
            lblErrMsg.Text = "Could not find the control ID for " + controlID;
        }
  
        return fieldValue;
    }
Pavlina
Telerik team
 answered on 25 Mar 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?