GridTemplateColumn column with TextBox

4 posts, 0 answers
  1. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 11 Oct 2012 Link to this post

    I have a templatecolumn with TextBox in the grid:
    <telerik:GridTemplateColumn DataField="Translation2"   AutoPostBackOnFilter="true" ShowFilterIcon="false" UniqueName="ForeignTranslation" AllowFiltering="true" FilterControlWidth="200px" 
             <asp:TextBox ID="txtTranslationText"  AutoPostBack="true" runat="server" Height="44px" OnTextChanged="txtTranslationText_TextChanged" TextMode="MultiLine"  ></asp:TextBox>
               <HeaderStyle Width="200px" />

    OnTextChanged I saves the data, as long as the user types "< with any characters >", it will errored out :
    "sys.winforms.PagesRequestManagerServerErrorException: an unknown error ocurred....". Please help how to avoid the error.
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 11 Oct 2012 Link to this post


    The problem is more specific to ASP.NET, which does not allow a page to postback when it find "<" or ">" in any of its input controls (i.e. TextBox) because of Cross Site Scripting attacks. If you want to allow the page to postback when those characters are found then set this ValidateRequest="false" in your <%@ Page %> declaration at the top of you page.

    I hope that helps.

    if not than please use RadEditor and Remove all unnecessary tools.

    Jayesh Goyani
  3. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 11 Oct 2012 Link to this post

    Thanks Jayesh. But why RadEditor allows <any text>. Will this also cause Cross Site Scripting attacks

    I have another question. I have 2 columns here, one column is textcolumn1 which is a bound column (bound to English text), the second column is the Translation2 GridTempletecolumn which has the text box -txtTranslationText (allow user the enter translation of the English) in it. When textcolumn1 bound to a longer text, I want the the height of the txtTranslationText  getting longer.  ie,  I want the height of the txtTranslationText based on the height of the grid cell auto expended height.  But the problem is I don't know how to find the height of the grid cell.

    On itemdatabound, I tried to get the cell height by :


    Unit theCellHight = e.Item.Height;  but it is always 0.

    Please help!


  4. Kostadin
    Kostadin avatar
    1733 posts

    Posted 16 Oct 2012 Link to this post

    Hi ,

    A possible approach is to set theTextMode property to MultiLine and handle on onkeyup and onkeydown events. When the scroll height is changed, you changed the size of the TextBox. Take a look at the following JavaScript code:
    function setHeight(txtdesc) {
       = txtdesc.scrollHeight + "px";

    Additionally I prepared a small sample so you could try it on your side.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top