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" 
             HeaderText="Translation2">
                 <ItemTemplate>
             <asp:TextBox ID="txtTranslationText"  AutoPostBack="true" runat="server" Height="44px" OnTextChanged="txtTranslationText_TextChanged" TextMode="MultiLine"  ></asp:TextBox>
                   </ItemTemplate>
               <HeaderStyle Width="200px" />
    </telerik:GridTemplateColumn>


    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
    2732 posts
    Member since:
    May 2010

    Posted 11 Oct 2012 Link to this post

    Hello,

    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.

    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. 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!

     

  5. Kostadin
    Admin
    Kostadin avatar
    1708 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.style.height = txtdesc.scrollHeight + "px";
            }

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

    Greetings,
    Kostadin
    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