开发者

Eval() in ASP. How to pass values on redirect

<asp:GridView ID="GridView1" runat="server" CssClass="style29">
            <Columns>
                <asp:TemplateField HeaderText="Send Message to Group">
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton2" runat="server" PostBackUrl='SendMessage.aspx?GroupName=<%# Eval("GroupName") %>'  Text='Send Message'></asp:LinkButton>

                    </ItemTempl开发者_StackOverflowate>

                </asp:TemplateField>

            </Columns>
        </asp:GridView>

I am redirecting the to SendMessage.ASPX page which has a text box, I have to pass the group name to that text box. Please help me guys I am new to programming. It gets redirected but how to pass that value to this text box below in SendMessage.aspx page.


Sorry I may have misunderstood your question, however the common pattern involves the query string

You can access the query string values as

if (String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["GroupID"]) == false) {
    String groupId = HttpContext.Current.Request.QueryString["GroupID"];
}

you would then be able to set this value to the textbox.Text property in your page load event, which will apply the value from the query string to the textbox. Generally, you want to check for null or empty strings before attempting to access the query string.

Also, always remember that this kind of action is often a target for malicious users to do malicous things with your website, so you must check inputs to ensure 'bad' inputs are ignored.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜