Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to avoid cross script reflected security issue for hidden html controls with in a gridview in asp.net with c#. I am using Visual Studio 2008 with c#.

I am fetching the hidden field values with in the gridview and in the source it is as below:
ASP.NET
<cc1:XDataGrid ID="grdDetails" runat="server" HorizontalAlign="Center" Width="100%"
                                        AutoGenerateColumns="False" CssClass="NeST_DATAGRID_FIXED_SIZE" OnItemCommand="grdDetails_ItemCommand"
                                        AllowCustomPaging="True" AllowPaging="True" OnPageIndexChanged="grdDetails_PageIndexChanged"
                                        OnPagerClicked="grdDetails_PagerClicked" PageSize="10">
                                        <AlternatingItemStyle BorderWidth="0px" CssClass="NeST_DATAGRID_CELLDATA2" Wrap="True">
                                        </AlternatingItemStyle>
                                        <ItemStyle BorderWidth="0px" CssClass="NeST_DATAGRID_CELLDATA" HorizontalAlign="Left"
                                            Wrap="True"></ItemStyle>
                                        <HeaderStyle CssClass="NeST_DATAGRID_HEADING" Height="20px"></HeaderStyle>
                                        <Columns>
                                            <asp:TemplateColumn HeaderText="Sl No.">
                                                <ItemTemplate>
                                                    <asp:Label ID="O_SecondaryCode" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.SlNo") %>'>
                                                    </asp:Label>
                                                    <input type="hidden" id="hidID" runat="server" value='<%# DataBinder.Eval(Container, "DataItem.MandateReference") %>' />
                                                    <input type="hidden" id="hidMandate" runat="server" value='<%# DataBinder.Eval(Container, "DataItem.MandateReference") %>' />
                                                </ItemTemplate>
                                                <HeaderStyle Width="4%"></HeaderStyle>
                                            </asp:TemplateColumn>


What I have tried:

In the item command I am fetching in the same as below:
 HtmlInputHidden hidID = (HtmlInputHidden)e.Item.FindControl("hidID");
string Id=hidID.toString();
Posted
Updated 11-Dec-18 1:42am
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900