Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
209 views
Hello,

I am using a RadGrid which is wrapped in a RadAjaxPanel.

This RadGrid contains a user control that we are using for the editing of grid data.

On the user control, I have several textboxes, a "Save" button and a "Cancel" button.

On the Save button, I have the OnClientClick set to OnClientClick = "return CanSave();".  (I have also tried setting OnClientClick to OnClientClick="return true;" and OnClientClick = "if (CanSave()) return true;", all with the same results.)

CanSave() is a javascript procedure defined in the user control.  My Javascript is wrapped in a RadScriptBlock.

CanSave() returns a TRUE if the Save should take place.  I have verified that my "return true" line is being executed in this function.

Here is my problem:

When CanSave() returns true, no postback is happening.  If I remove the RadGrid from the RadAjax panel, it works fine when I click "Save" and CanSave() runs and returns true.  Or, if I leave the RadGrid in the RadAjax panel, and remove the OnClientClick event from the Save button and cilck the Save button, the PostBack occurs and everything works fine.

So, in short, having the RadGrid in a RadAjaxPanel and having the OnClientClick assigned to CanSave() on my user control that edits the data in the grid causes no Post Back to occur when clicking the Save button on my user control that edits the data in my RadGrid.

Any ideas as to what I might be doing wrong?  Code is below.

Here is my RadGrid:
<asp:Panel ID="pnlNewsAdmin" runat="server">
        <telerik:RadAjaxPanel ID="radAjaxPanel_MLONewsAdmin" runat="server" LoadingPanelID="radAjaxLoadingPanel_MLONewsAdmin">
            <telerik:RadAjaxLoadingPanel ID="radAjaxLoadingPanel_MLONewsAdmin" runat="server" />
            <telerik:RadGrid ID="rgNewsAdmin" runat="server" HeaderStyle-Font-Size="Smaller"
                ItemStyle-Font-Size="Smaller" AllowMultiRowSelection="false" AlternatingItemStyle-Font-Size="Smaller"
                AllowPaging="true" PageSize="10" AllowSorting="true" AllowFilteringByColumn="false"
                AutoGenerateColumns="false" GridLines="None" Skin="Default" ItemStyle-BackColor="#ddeeff"
                AlternatingItemStyle-BackColor="White" HeaderStyle-BackColor="AliceBlue" HeaderStyle-CssClass="BACGridHeader"
                OnNeedDataSource="rgNewsAdmin_OnNeedDataSource" OnInsertCommand="rgNewsAdmin_OnInsertCommand"
                OnUpdateCommand="rgNewsAdmin_OnUpdateCommand" OnDeleteCommand="rgNewsAdmin_OnDeleteCommand"
                OnItemCommand="rgNewsAdmin_OnItemCommand">
                <PagerStyle Mode="NumericPages" />
                <MasterTableView ShowHeadersWhenNoRecords="true" DataKeyNames="ManageNewsID" CommandItemDisplay="Top"
                    InsertItemPageIndexAction="ShowItemOnCurrentPage">
                    <CommandItemSettings AddNewRecordText="Add News Item..." />
                    <Columns>
                        <telerik:GridBoundColumn DataField="ManageNewsID" Visible="false" />
                        <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" />
                        <telerik:GridBoundColumn DataField="URL" HeaderText="URL" SortExpression="URL" />
                        <telerik:GridTemplateColumn HeaderText="Start Date" SortExpression="StartDate">
                            <ItemTemplate>
                                <%# (DataBinder.Eval(Container,"DataItem.StartDate") != null ? DateTime.Parse(DataBinder.Eval(Container,"DataItem.StartDate").ToString()).ToShortDateString() : "") %>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Expire Date" SortExpression="ExpireDate">
                            <ItemTemplate>
                                <%# (DataBinder.Eval(Container,"DataItem.ExpireDate") != null ? DateTime.Parse(DataBinder.Eval(Container,"DataItem.ExpireDate").ToString()).ToShortDateString() : "") %>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="SelectedRoleDescriptions" HeaderText="Roles"
                            SortExpression="SelectedRoleDescriptions" ItemStyle-Width="275px" />
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="edit.gif"
                            UniqueName="EditColumn" EditText="Edit News Item" />
                        <telerik:GridButtonColumn ConfirmText="Delete News Item?" UniqueName="DeleteColumn"
                            Text="Delete News Item" ConfirmTitle="Delete" ConfirmDialogType="RadWindow" CommandName="Delete"
                            ButtonType="ImageButton" ImageUrl="delete.gif" />
                    </Columns>
                    <EditFormSettings EditColumn-ButtonType="ImageButton" EditColumn-UniqueName="EditColumn"
                        UserControlName="~/EditItem.ascx" EditFormType="WebUserControl" />
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
    </asp:Panel>


Here is my user control:
<telerik:RadScriptBlock ID="radScriptBlock_EditMLONewsItem" runat="server">
    <script type="text/javascript">
        String.prototype.trim = function()
        {
            return this.replace(/^\s\s*/,'').replace(/\s\s*$/,'');
        }
          
        function CanSave()
        {
            var errorMsg = "";
            var txtDescription = $get("<%= txtDescription.ClientID %>");
            var txtURL = $get("<%= txtURL.ClientID %>");
            var rdpStartDate = $find("<%= rdpStartDate.ClientID %>");
            var rdpExpireDate = $find("<%= rdpExpireDate.ClientID %>");
              
            var description = txtDescription.value.trim();
            var url = txtURL.value.trim(); 
            var startDate = rdpStartDate.get_selectedDate();
            var expireDate = rdpExpireDate.get_selectedDate();
              
            if (description.length == 0)
            {
                errorMsg = "Description\n";
            }
              
            if (url.length == 0)
            {
                errorMsg = errorMsg + "URL\n";
            }
              
            if (startDate == null)
            {
                errorMsg = errorMsg + "Start Date\n";
            }
              
            if (expireDate == null)
            {
                errorMsg = errorMsg + "Expire Date\n";
            }
              
            if ((startDate != null) && (expireDate != null))
            {
                if (startDate > expireDate)
                {
                    errorMsg = errorMsg + "Start Date must occur before Expire Date.\n";
                }
            }
              
            try
            {
                if (!HasRolesSelected())
                {
                    errorMsg = errorMsg + "At least one User Role must be selected.\n";
                }
            }
            catch(e)
            {}
              
            if (errorMsg.length > 0)
            {
                alert("The following items must be completed in order to save this News Item:\n" + errorMsg);
                return false;
            }
              
            return true;
        }
    </script>
</telerik:RadScriptBlock>
  
<table>
    <tr>
        <td valign="top" width="425px">
            <table>
                <tr>
                    <td>
                        <asp:Label ID="lblDescription" runat="server" Text="Description" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtDescription" runat="server" MaxLength="255" Width="300px" Text='<%# ((DataBinder.Eval(Container,"DataItem.Description").ToString() != "") ? DataBinder.Eval(Container,"DataItem.Description") : "") %>' />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblURL" runat="server" Text="URL" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtURL" runat="server" MaxLength="255" Width="300px" Text='<%# ((DataBinder.Eval(Container,"DataItem.URL").ToString() != "") ? DataBinder.Eval(Container, "DataItem.URL") : "") %>' />
                          
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblStartDate" runat="server" Text="Start Date" />
                    </td>
                    <td>
                        <telerik:RadDatePicker ID="rdpStartDate" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblExpireDate" runat="server" Text="Expire Date" />
                    </td>
                    <td>
                        <telerik:RadDatePicker ID="rdpExpireDate" runat="server" />
                    </td>
                </tr>
            </table>
        </td>
        <td>
            <table>
                <tr>
                    <td valign="top">
                        <asp:Label ID="lblRoles" runat="server" Text="Roles" />
                    </td>
                    <td>
                        <RoleSelector:roleSelector ID="roleSelector" runat="server" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<div style="padding-top: 10px;">
    <asp:Button ID="btnInsert" runat="server" Text="Save" CommandName="PerformInsert" OnClientClick="if(CanSave())return true;"
        Visible='<%# (DataBinder.Eval(Container,"DataItem.ManageNewsID").ToString() != "" ? false : true) %>' />
    <asp:Button ID="btnUpdate" runat="server" Text="Save" CommandName="Update" OnClientClick="if (CanSave()) return true;" Visible='<%# (DataBinder.Eval(Container,"DataItem.ManageNewsID").ToString() != "" ? true : false) %>' />
    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="false" />
</div>
Sébastien
Top achievements
Rank 2
 answered on 10 Mar 2011
3 answers
180 views
hi
anybody can u  help me. i am new to telerik controls.
i am trying to display a gird in edit mode. (please see this link )
http://www.telerik.com/help/aspnet-ajax/images/grd_EditMode_markedup.png
what should i write in <telerik:GridEditCommandColumn />
this is my code:
<MasterTableView DataKeyNames="configID" AllowAutomaticInserts="true" AllowAutomaticUpdates="true">
                <Columns>
                    <telerik:GridBoundColumn DataField="CONFIGID" HeaderText="ConfigID"
                        UniqueName="ConfigID" DataType="System.Int32" EditFormColumnIndex="1"/>
                    <telerik:GridBoundColumn DataField="CATEGORY" HeaderText="Category"
                        UniqueName="category" DataType="System.String" EditFormColumnIndex="2"/>
                    <telerik:GridBoundColumn DataField="CATEGORY" EditFormColumnIndex="3"
                        DataType="System.String" HeaderText="Category" UniqueName="Category" />
                    <telerik:GridBoundColumn DataField="ITEM" HeaderText="Item"
                        UniqueName="item" DataType="System.String" EditFormColumnIndex="4"/>
                    <telerik:GridBoundColumn DataField="S1" HeaderText="S1"
                        UniqueName="s1" DataType="System.String"  EditFormColumnIndex="5"/>
                    <telerik:GridBoundColumn DataField="S2" HeaderText="S2"
                        UniqueName="s2" DataType="System.String"  EditFormColumnIndex="6"/>
                    <telerik:GridBoundColumn DataField="N1" HeaderText="N1"
                        UniqueName="N1" DataType="System.String"  EditFormColumnIndex="7"/>
                    <telerik:GridBoundColumn DataField="createdwhen" HeaderText="Created When"
                        UniqueName="createdwhen" DataType="System.DateTime"/>
                    <telerik:GridBoundColumn DataField="createdby" HeaderText="Created By"
                        UniqueName="createdby" DataType="System.String"/>
                    <telerik:GridBoundColumn DataField="updatedwhen" HeaderText="Updated When"
                        UniqueName="updatedwhen" DataType="System.DateTime"/>  
<telerik:GridEditCommandColumn />
                </Columns>
                </MasterTableView>
what should i write in this? any idea please
protected void configGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is Telerik.Web.UI.GridEditableItem && e.Item.IsInEditMode)
            {
                //the item is in edit mode
                Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem;
                //do something here
                
            }
            else if (e.Item is Telerik.Web.UI.GridDataItem)
            {
                //the item is in regular mode
                Telerik.Web.UI.GridDataItem dataItem = e.Item as Telerik.Web.UI.GridDataItem;
                
            }
        }
please help me
Princy
Top achievements
Rank 2
 answered on 10 Mar 2011
1 answer
165 views
I have a requirement to validate some of the RadDatePicker and RadTimePicker fields on our form.

If invalid characters are typed into these fields, although a yellow triangle is displayed on the control, the user can still submit the form.

The examples I've seen to remedy this involved using a RequiredFieldValidator.

However, in our case, not all date or time fields will have to be completed - some may be left blank.

Is there a solution for this, preferably using both client side and server side validation?

Matt.
Shinu
Top achievements
Rank 2
 answered on 10 Mar 2011
3 answers
122 views
Dears,

I downloaded the Telerik Ajax Controls and I'm trying to apply the  Grid View as the following :

<telerik:RadGrid ID="RadGrid1" runat="server" CssClass="RadGrid" GridLines="None"
AllowPaging="True" PageSize="20" AllowSorting="True" AutoGenerateColumns="False"
ShowStatusBar="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted"
OnItemUpdated="RadGrid1_ItemUpdated" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender">
<MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="الأجراء">
<CommandItemSettings ExportToPdfText="Export to Pdf" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
</ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn CancelText="الغاء" EditText="تعديل" InsertText="حفظ"
UpdateText="تعديل">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn UniqueName="Case Id" HeaderText="رقم الحالة" DataField="الحالة">
<HeaderStyle ForeColor="Silver" Width="20px"></HeaderStyle>
<ItemStyle ForeColor="Gray" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Activity UID" HeaderText="رقم الأجراء" DataField="الأجراء">
<HeaderStyle ForeColor="Silver" Width="20px"></HeaderStyle>
<ItemStyle ForeColor="Gray" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Type" HeaderText="نوع الأجراء" DataField="نوع">
<HeaderStyle Width="60px"></HeaderStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Created" HeaderText="تاريخ الأجراء" DataField="تاريخ"
DataFormatString="{0:d}">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Owned By" HeaderText="الموظفين" DataField="الموظفين">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Description" HeaderText="الوصف" DataField="الوصف">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="حذف" UniqueName="column">
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template">
<EditColumn FilterControlAltText="Filter EditCommandColumn1 column" UniqueName="EditCommandColumn1">
</EditColumn>
<FormTemplate>
<table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
style="border-collapse: collapse; background: white;">
<tr class="EditFormHeader">
<td colspan="2" style="font-size: small">
<b></b>
</td>
</tr>
<tr>
<td colspan="2">
<b></b>
</td>
</tr>
<tr>
<td>
<table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
رقم الأجراء:
</td>
<td>
<asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("الأجراء") %>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td>
الموظفين:
</td>
<td>
<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("الموظفين") %>' TabIndex="1">
</asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
تاريخ الأجراء:
</td>
<td>
<telerik:RadDatePicker ID="BirthDatePicker" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Eval("تاريخ") %>'
TabIndex="4">
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td>
نوع الأجراء
</td>
<td>
<asp:DropDownList ID="ddlTOC" runat="server" TabIndex="7" AppendDataBoundItems="True">
<asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</td>
<td>
<table id="Table1" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
<tr>
<td>
الوصف:
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox1" Text='<%# Bind("الوصف") %>' runat="server" TextMode="MultiLine"
Rows="5" Columns="40" TabIndex="5">
</asp:TextBox>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="btnUpdate" Text='<%#"تعيل" %>' runat="server" CommandName='<%# "Update" %>'>
</asp:Button>&nbsp;
<asp:Button ID="btnCancel" Text="الغاء" runat="server" CausesValidation="False" CommandName="Cancel">
</asp:Button>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<ClientEvents OnRowDblClick="RowDblClick" />
</ClientSettings>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
</telerik:RadGrid>

And I'm trying to get the Asp dropdownlist from it in ItemDataBound By this Code :
Dim dropDownList As DropDownList = DirectCast(RadGrid1.FindControl("ddlTOC"), DropDownList)

But this Return Nothing

Any Herp I will be grateful
Thank you

khalil_ck2002
Top achievements
Rank 1
 answered on 10 Mar 2011
4 answers
233 views
I am using the RadGrid and have defined a template for insert and editing. The template includes multiple text boxes and button.

When teh button is clicked it brings up a window that contains access to a google map. The user can select a location on teh map and click a submit button and the address of the location on the map is placed in the text box on the edit form in the grid.

The only way  van get this to work is to access the text box as a fully qualified element name

i.e. 

document.getElementById(

"ctl00_ContentPlaceHolder1_JobGrid_ctl00_ctl02_ctl02_txtLocation").value = place;

The problem I am ruinning into is that the element name is different for each row in the grid for example
this is the element name for the first row in the grid when the edit form is opened.

 

    document.getElementById("ctl00_ContentPlaceHolder1_JobGrid_ctl00_ctl05_txtLocation").value = place;

So my question is; how can I get access to the text box on the edit form regardless of which row is being edited. I am using javascript on the client side to interact with the text box so it needs to be a client side solution not a server side solution.

Thanks

Rod

Princy
Top achievements
Rank 2
 answered on 10 Mar 2011
7 answers
120 views
Hello,
I am testing Telerik Ajax controls in Visual Studio 2008 .net framework 3.5.
In separate test project all went well.
Then I try to add controls to an old project that we are tring to improve and nothing happends.
If I try to add controls in source view i receive the message "The Operation could not be completed".
I have done reloading references, closed solution, closed VS, reset toolbox, readding controls to toolbox.
Before starting digging up how to make it work, I want to know if you have a  known solution for this problem.

Erjan Gavalji
Telerik team
 answered on 10 Mar 2011
4 answers
219 views
I have a RadGrid with a Form Template for Inserting and Updating the data.  I would like to enable Ajax for the entire grid and for individual elements within the Grid.  I am using the AjaxManager and AjaxManagerProxy to attempt to accomplish this.  I have for example an AjaxManagerProxy within with FormTemplate which enables Ajax for a second RadGrid which sits within the EditForm and a second AajxManagerProxy inside a user control also within the edit form.  These all work as expected, but when I add the main RadGrid to the main AjaxManager all of the "sub" ajax updates cause the whole Grid to update rather than just the small section which was updating previously. 

To shed a but more light on what I am looking for, this is an example: 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="admin_Default2"

Title="Untitled Page" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>CSA - Compliance, Safety, Accountability</title>

</head>

<body runat="server" id="MyBody">

<a style="display: none;" href="#content">Skip to Content</a>

<form id="form1" runat="server">

<telerik:RadScriptManager ID="scriptManager" runat="server">

</telerik:RadScriptManager>

<telerik:RadAjaxManager runat="server" ID="ajaxManager">

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="grid">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="grid" />

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManager>

<telerik:RadGrid runat="server" ID="grid" AutoGenerateColumns="true" AutoGenerateEditColumn="true"

OnNeedDataSource="getDocuments" Width="300">

<MasterTableView>

<EditFormSettings EditFormType="Template">

<FormTemplate>

<telerik:RadAjaxManagerProxy runat="server" ID="proxy">

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="btn">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="txt" />

<telerik:AjaxUpdatedControl ControlID="lbl" />

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManagerProxy>

<telerik:RadAsyncUpload runat="server" ID="fileUpload" />

<asp:TextBox runat="server" ID="txt" />

<asp:Button runat="server" ID="btn" OnClick="click" Text="Add" />

<asp:Label runat="server" ID="lbl" />

<asp:Button runat="server" CommandName='<%=RadGrid.UpdateCommandName%>' Text="Update" />

</FormTemplate>

</EditFormSettings>

</MasterTableView></telerik:RadGrid>

</form>

</body>

</html>



public partial class admin_Default2 : System.Web.UI.Page


{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    protected void getDocuments(object sender, GridNeedDataSourceEventArgs e)

    {

        (sender as RadGrid).DataSource = new int[] { 2, 3, 4, 5, 6, 7 };

    }

    protected void click(object sender, EventArgs e)

    {

        ((sender as Button).NamingContainer.FindControl("lbl") as Label).Text +=

"<br/>" + ((sender as Button).NamingContainer.FindControl("txt") as TextBox).Text;

        ((sender as Button).NamingContainer.FindControl("txt") as TextBox).Text = "";

    }

}



The final result should be that clicking the add does not submit the rest of the edit panel, but clicking the other button does
Pavlina
Telerik team
 answered on 10 Mar 2011
1 answer
78 views
Hi, I am working with Q3 reporting and .net ajax and have a report that I am trying to incorporate in a tabstrip/multipage approach. The report works/displays fine outside of a PageView within the multipage, but if I drop it into a pageview, this disables all the tabs in the tabstrip and you can no longer navigate to content in any of the tabs. Using Firebug, there are no javascript errors. The tabs can be selected and change color, but multipage selection / switching no longer happens. Any thoughts out there?
Peter
Telerik team
 answered on 10 Mar 2011
8 answers
178 views
Hi,

I would like to validate the default inline template insert, basically I don't want to let the user create appointments that don't have subject inserted.

Can this be achieved? For some reason 'OnClientAppointmentInserting' is not getting triggered.

Thanks in advance.

Daryl
Veronica
Telerik team
 answered on 10 Mar 2011
2 answers
251 views

I'm getting a security exception when using the RadEditor in Medium Trust

Web.config 
 

<

 

system.web  

 

 

<

 

trust level="Medium" originUrl="" />

 

 

 

....
... 

 

<httpHandlers>
      <remove verb="*" path="*.asmx" />
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
      <add path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" validate="false" />
      <add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false" />
      <add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false" />
      <add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false" />
      <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" verb="*" validate="false" />
  
    </httpHandlers>
  
<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ScriptModule" />
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <remove name="RadUploadModule" />
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode,runtimeVersionv2.0" />
      <remove name="RadCompression" />
      <add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode,runtimeVersionv2.0" />
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <remove name="ScriptHandlerFactory" />
      <remove name="ScriptHandlerFactoryAppServices" />
      <remove name="ScriptResource" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  
      <remove name="ChartImage_axd" />
      <add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode,runtimeVersionv2.0" />
      <remove name="Telerik_Web_UI_SpellCheckHandler_axd" />
      <add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode,runtimeVersionv2.0" />
      <remove name="Telerik_Web_UI_DialogHandler_aspx" />
      <add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode,runtimeVersionv2.0" />
      <remove name="Telerik_RadUploadProgressHandler_ashx" />
      <add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode,runtimeVersionv2.0" />
      <remove name="Telerik_Web_UI_WebResource_axd" />
  
      <add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" verb="*" preCondition="integratedMode,runtimeVersionv2.0" />
  
    </handlers>
    <defaultDocument>
      <files>
        <clear />
        <add value="default.aspx" />
        <add value="index.html" />
        <add value="Default.htm" />
        <add value="index.htm" />
        <add value="Default.asp" />
        <add value="iisstart.htm" />
      </files>
    </defaultDocument>
  </system.webServer>

Master Page
  
<form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" OutputCompression="AutoDetect" ScriptMode="Release" runat="server" LoadScriptsBeforeUI="True"
        EnableScriptCombine="True">
        <Scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" OutputCompression="AutoDetect"  runat="server">
    </telerik:RadStyleSheetManager>
    <%--RestoreOriginalRenderDelegate="false" needed for godaddy hosting, which runs in Medium Trust--%>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" RestoreOriginalRenderDelegate="false">
    </telerik:RadAjaxManager>
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server">
    </telerik:RadSkinManager>
    <telerik:RadWindowManager EnableEmbeddedSkins="true" ID="RadWindowManager1" runat="server"
        InitialBehaviors="None" EnableViewState="true" DestroyOnClose="true" Behaviors="Close, Resize, Maximize, Move"
        ShowContentDuringLoad="true">
        <Windows>
            <telerik:RadWindow runat="server" InitialBehaviors="None" Left="" Top="" ID="Features"
                Behaviors="Close, Resize, Maximize, Move" Height="400" Modal="True" VisibleStatusbar="false"
                Width="1000px" DestroyOnClose="false" ShowContentDuringLoad="true" ReloadOnShow="True"
                OnClientClose="ClearWindow" Animation="None" NavigateUrl="">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <telerik:RadFormDecorator ID="RadFormDecorator2"  DecoratedControls="All" runat="server"
        DecorationZoneID="ZoneID1"></telerik:RadFormDecorator>
    <div class="DesignWidth" style="height: 100%;">
        <div id="ZoneID1" style="height: 100%;">
            <uc1:Header ID="Header1" runat="server" />
            <uc2:Menu ID="Menu1" runat="server" />
            <telerik:RadAjaxPanel ID="PagePanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"
                RestoreOriginalRenderDelegate="false">
                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>
            </telerik:RadAjaxPanel>
        </div>
    </div>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1"  runat="server" HorizontalAlign="Center"
        Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    </form>

Content Page
  
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/TenkillerTaxidermy.Master" CodeBehind="Test.aspx.vb" Inherits="TenkillerTaxidermy.Test" %>
  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  
<telerik:RadEditor ID="reap_HTMLContent" ToolbarMode="Default" ContentAreaMode="Div"
                                    AllowScripts="true" runat="Server" Width="875px" AutoResizeHeight="false">
                                    <Modules>
                                        <telerik:EditorModule Name="RadEditorHtmlInspector" Enabled="false" Visible="false" />
                                        <telerik:EditorModule Name="RadEditorNodeInspector" Enabled="false" Visible="false" />
                                        <telerik:EditorModule Name="RadEditorDomInspector" Enabled="false" Visible="false" />
                                        <telerik:EditorModule Name="RadEditorStatistics" Enabled="true" Visible="true" />
                                    </Modules>
                                </telerik:RadEditor>
  
</asp:Content>


Exception
Security Exception 
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 
  
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
  
Source Error: 
  
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
  
Stack Trace: 
  
  
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.SpecialDemand(PermissionType whatPermission, StackCrawlMark& stackMark) +0
   System.Security.CodeAccessPermission.DemandInternal(PermissionType permissionType) +30
   System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +143
   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +231
   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph) +17
   System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +3316
  
   
  
  
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955
Rumen
Telerik team
 answered on 10 Mar 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?