Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
129 views
Hi,

I open an aspx page into the editor.  The user change its content and later I want to save it in the same file.

For so I have used a snippet code that I have found in ASP.NET for AJAX 2009 Q1.
        private bool _contentUpdated = false
        private string _editorContent = string.Empty; 
 
        private string EditorMatchEvaluator(Match m) 
        { 
            _contentUpdated = true
            string newContent = m.Groups[1].Value + _editorContent + "</content>"
            return newContent; 
        } 
 
        private void SaveInCurrentFile(RadEditor editor) 
        { 
            try 
            { 
                //read file 
                string physicalFileName = MapPathSecure(this.AppRelativeVirtualPath); 
                FileStream fs = new FileStream(physicalFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); 
                StreamReader sr = new StreamReader(fs); 
                string pageContent = sr.ReadToEnd(); 
 
                //update content 
                _contentUpdated = false
                _editorContent = editor.Content; 
                MatchEvaluator mEvaluator = new MatchEvaluator(EditorMatchEvaluator); 
                pageContent = Regex.Replace(pageContent, "(<(\\w+):RadEditor[^>]+?ID\\s*=\\s*['\"]?" + editor.ID + "['\"]?[^>]*>[\\s\\S]*?<content>)[\\s\\S]*?</content>", mEvaluator, RegexOptions.IgnoreCase | RegexOptions.Compiled); 
                //update file 
                if (_contentUpdated) 
                { 
                    fs.Seek(0, SeekOrigin.Begin); 
                    StreamWriter sw = new StreamWriter(fs); 
                    sw.BaseStream.SetLength(0); 
                    sw.Write(pageContent); 
                    sw.Flush(); 
                    sw.Close(); 
                } 
                else 
                { 
                    sr.Close(); 
                } 
            } 
            catch (Exception) 
            { 
                //"The File Encoding you have provided is not supported!" 
                //"Refresh the screen and try again!" 
                //"Another process or user is using the resource (ascx/aspx file) you are trying to update." 
                //"Check if the ASPNET user (IIS5) / NETWORK SERVICE account (IIS6) has write privileges for this file." 
            } 
        } 
    } 

I get an error in EditorMatchEvaluator function, with "Match" variable.
              Error    1    The type or namespace name 'Match' could not be found (are you missing a using directive or an assembly reference?)

I have added all references as possible but the problem still exist.

Do you know what am I missing?

Thank you in advance.


Patxi
Top achievements
Rank 1
 answered on 23 Apr 2009
1 answer
79 views
Hi

I have a problem with a RadGrid using paging inside a resizable RadPane. The RadGrid is set to 100% height. When Im resizing the RadPane the grid is also resized to fit the panes height perfectly. All is fine until I add a RadAjaxManager to support partial updates on my page. Then the RadGrid is not resizing properly. Its fixed at a minimal height no matter how I resize my pane.

Here is the code Im using. All is fine with the RadAjaxManager commented but when I uncomment it and use the RadAjaxManager I get this strange effect.

Ideas anyone?

<%@ Page Language="c#" CodeFile="GridTest.aspx.cs" AutoEventWireup="false" Inherits="GridTest" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<body class="BODY"
    <form id="Form1" method="post" runat="server"
        <asp:ScriptManager ID="ScriptManager" runat="server" /> 
 
<%-- 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <AjaxSettings> 
                 <telerik:AjaxSetting AjaxControlID="RadGrid1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
--%> 
 
        <telerik:RadSplitter ID="RadSplitter1" Width="700px" runat="server" Orientation="Horizontal"
            <telerik:RadPane ID="gridPane" runat="server" Height="307px" 
                Scrolling="None"
 
                <telerik:RadGrid AllowPaging="true" PageSize="40" Width="100%" Height="100%" Style="border: 0; 
                    outline: none" ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1"
                    <MasterTableView AllowPaging="true" TableLayout="Fixed" /> 
                    <PagerStyle Mode="NumericPages" /> 
                    <ClientSettings EnableRowHoverStyle="true"
                        <Selecting AllowRowSelect="true" /> 
                        <Scrolling AllowScroll="true" UseStaticHeaders="true" /> 
                    </ClientSettings> 
                </telerik:RadGrid> 
 
            </telerik:RadPane> 
 
            <telerik:RadSplitBar CollapseMode="Both" ID="RadSplitBar2" runat="server" EnableResize="True"
 
            </telerik:RadSplitBar> 
            <telerik:RadPane ID="listBoxPane" runat="server" BackColor="#d9eeff"
                Bottom Pane 
            </telerik:RadPane> 
        </telerik:RadSplitter> 
 
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"  
            ConnectionString="<%$ ConnectionStrings:RejusUnderhÃ¥llningConnectionString %>"  
            SelectCommand="SELECT RecID FROM [Activity]"></asp:SqlDataSource> 
    </form> 
</body> 
</html> 
Dimo
Telerik team
 answered on 23 Apr 2009
5 answers
389 views
Hi,
In my application I would like to add a Button for each group header.
When the user clicks on the Button I want him to be able to insert a new record.
In order for the Insert to work I need to read an ID field value, which is used to Group the records (GroupID).

Here's what I have been able to get so far:
1.I was able to add button to GroupHeader in the Grid's ItemCreated event:
======
if (e.Item is GridGroupHeaderItem)
                {
                    GridGroupHeaderItem groupHeader=         (GridGroupHeaderItem)e.Item;
                   
                    Button objButton = new Button();
                    objButton.CommandName = "Add";
                    objButton.ID = "Button_Add";
                    objButton.Text = "Add ";
                    groupHeader.Cells[0].Controls.Add(objButton);
                   
                }

====

2. Now when the User Clicks on the Button I can get the GroupHeaderItem for which the Button was clicked by interception the ItemCommand Event.

3.I used the FireCommandEvent("InitInsert", string.Empty); to get the Insert input boxes. One problem here is that the Inser section comes on the Last page of the Grid (Paging enabled) can this be fixed?

4. My Main concern is that I am not able to get the GroupID (field in my DB) that is used in GridGroupByField  at design time.
I need this value to be able to insert the record. Is there a way to do this?
I can get this value from the GroupHeader or from any Row in the Group, where the Button was clicked.

Thanks for your help.

-Brenda
Princy
Top achievements
Rank 2
 answered on 23 Apr 2009
1 answer
99 views
I finally after much irritation got the insert to work. Im new to the objectdatasource AND the rad controls.

I can't seem to get my datakey to show up as a parameter in my delete method...The delete is being called but the parameter is null. If you have any ideas about how to get the update to work that would be helpful also.

  <asp:objectdatasource ID="objdsRoles" runat="server"  
      selectmethod="GetAllRoles"  
      deletemethod="DeleteRole" 
      insertmethod="InsertRole" 
      oldvaluesparameterformatstring="original_{0}" 
      typename="MyNamespace.Data.Helpers"   
      > 
      <insertparameters> 
         <asp:controlparameter controlid="txtRoleName" type="String" name="RoleName" /> 
      </insertparameters> 
      <deleteparameters> 
         <asp:parameter name="Role"  type="String" /> 
      </deleteparameters> 
</asp:objectdatasource> 
 
 <telerik:radgrid id="rgRoles" runat="server"  
      mastertableview-editmode="InPlace"  
      allowautomaticupdates="True"  
      datasourceid="objdsRoles"  
      gridlines="None"  
      autogenerateeditcolumn="True" 
      autogeneratedeletecolumn="true"  
      ondeletecommand="rgRoles_OnDeleteCommand"
      <headercontextmenu enabletheming="True"
         <collapseanimation duration="200" type="OutQuint" /> 
      </headercontextmenu> 
      <mastertableview datakeynames="Role"
      </mastertableview> 
   </telerik:radgrid> 
 

//Code Behind stuffs.... 
void  rgRoles_OnDeleteCommand(object source, GridCommandEventArgs e) 
   { 
      objdsRoles.Delete(); 
   } 
 
//Code to delete the roll that is showing the null value 
 
public void DeleteRole( string Role ) 
      { 
         try 
         { 
            Roles.DeleteRole(Role, true); 
         } 
         catch( Exception ex ) 
         { 
            throw new Exception( "Failed to delete role.", ex ); 
         } 
      } 

Princy
Top achievements
Rank 2
 answered on 23 Apr 2009
1 answer
95 views

For a webapplication i am working on i need to extend the LinkManager with some new functionality. What i would like is to add a new asp.net databound dropdownlist. To bind the datasource to the dropdownlist control i need to have some kind of code behind, since that part is compiled into the Telerik.Web.UI.dll library i guess it is not possible??

The other 2 options that came to my mind is filling the HTML combobox using ajax by calling a webservice or just create an new custom dialog. Are there any other options??

Thanks in advance

 

Tervel
Telerik team
 answered on 23 Apr 2009
6 answers
154 views
From forum post and article I found on your site, I'm using the following to put a new node in edit mode.  When I run it, the page can find the treeview but I get a js error on the bolded line below saying the property/method is not supported by the object. I tried both lower and uppercase 'f' (FindNodeByValue and findNodeByValue) to no avail.  Do you know what might be wrong?

function HightlightNode(text)
        {
            var node = <%=RadTreeViewProject.ClientID%>.findNodeByValue(text);
            if (node != null)
            {
                node.StartEdit();
            }

        }
Atanas Korchev
Telerik team
 answered on 23 Apr 2009
1 answer
137 views
Hi
Issue #1:
   I used Rad grid with in User control.  The User Control have some set of Function . like Area Associations    wtith drop down, like wise Country, State, City.  When i Choose the Country drop down values that time loaded the related cities in Second Drop down like wise...
and Also some Dynamic Control are there for example When i Click the button that time the automatic row generated... my problem is i Edit Come text box values in Update mode. then i click this button that time the Edited values is disappear . and database values is display again.  How can i Solve this problem. the Edit Mode Code event i wrote in Code Behind C#.Net.

Issue #2
   i could not call the Ajax in edit mode drop down and another control How can i call the Ajax in edit mode Control . For example The above example area association country, state, city.  is not properly doing in Ajax in Edit Mode. and Button Click event the Auto Generated Column is not Working the Ajax. How can i Fix this Problem

Regards
G. Manikandan
Princy
Top achievements
Rank 2
 answered on 23 Apr 2009
1 answer
83 views
Hi All

I have a wide grid, so I enabled scrolling, everything seems perfect until I did the following:

in IE7, in the lower right corner, there is a zoom tool, (something like a combo box), I selected (75%), and I scrolled the horizontal scroll, the data and the headers of the columns disappeared

please give a try on this demo:

http://demos.telerik.com/aspnet-ajax/grid/examples/client/scrolling/defaultcs.aspx

note: it works fine on Firefox 3...

can you tell me how to fix it

Regards


Dimo
Telerik team
 answered on 23 Apr 2009
6 answers
278 views
hi
I have a radscriptmanager in masterpage..in contentpage i have a panel..inside that panel i placed a textbox.when i click on a button the panel is loaded.then the textbox in it should be get focused.i used the below code.but its not working
 Protected Sub tooltipAdd_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles tooltipAdd.Load  
        ' txtTitle.Focus()  
        Dim s As RadScriptManager  
         
        s = DirectCast(Me.Master.FindControl("RadAjaxManager1"), RadScriptManager)  
        s.SetFocus(txtTitle) 
thanks
Priya
Top achievements
Rank 1
 answered on 23 Apr 2009
1 answer
207 views
Hello,

We have a 2 level Hierarchy grid. Like this but 2 levels http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/declarativerelations/defaultcs.aspx

By default, the top level grid is collapsed and you have to click the little expand button on the left to show the sub-grid for each row. We want to use a telerik Toolbar above the grid and have an "Expand all" link so the user can click and expand all the rows to show the level 2 grids--thus expanding all the grids to show sub-grids.

Sample code? Thanks guys!
Shinu
Top achievements
Rank 2
 answered on 23 Apr 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?