This is a migrated thread and some comments may be shown as answers.

GridTemplateColumn column with TextBox

3 Answers 294 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 11 Oct 2012, 04:42 PM
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.

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 11 Oct 2012, 05:29 PM
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
0
JJ
Top achievements
Rank 1
answered on 11 Oct 2012, 08:17 PM
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!

 

0
Kostadin
Telerik team
answered on 16 Oct 2012, 05:19 PM
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.
Tags
Grid
Asked by
JJ
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
JJ
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or