Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In aspx page, i am using repeater in which i have binded command argument to a button, so on the click of the butoon i need to pass value to ascx page (user control page)



XML
<asp:Repeater ID="RptMessage" runat="server">
                       <ItemTemplate>
                           <tr>
                               <td width="99%">
                                   <label>
                                                   <table cellpadding="4" cellspacing="2">
                                                       <tr>
                                                           <td><asp:Button ID="BtnMsg" runat="server" Text="Select" CommandArgument='<%# Eval("templateId")%>' OnClick="select"/>
                                                           </td>
                                                           <td valign="top">
                                                               <strong style="font-size: medium">
                                                                   <%# Eval("templateName")%>
                                                               </strong>
                                                               <br />
                                                               <br />
                                                               <%# Eval("templateText")%></strong>
                                                           </td>
                                                       </tr>
                                                   </table>

                                   </label>
                               </td>
                           </tr>
                       </ItemTemplate>
                       <FooterTemplate>
                           </table>
                       </FooterTemplate>
                   </asp:Repeater>






C#
protected void select(object sender, EventArgs e)
    {
        Button btnM = (Button)sender;
        Response.Redirect("message_send.ascx?Tid=" + btnM.CommandArgument);
    }





This is not working please help
Posted

You cannot do a Redirection to an UserControl ( ascx extension ). Usercontrol should be always rendered as part of the Parent WebPage where its added. So Make the Redirection( also add the querystring) to the WebPage ( Parent Page) where the UserControl is used/Added and fetch the QueryString Value .
 
Share this answer
 
You can not redirect. Its a control. It is used as a part of a page.
 
Share this answer
 

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