cdonner
cdonner

Reputation: 37718

PostbackUrl and Query String Parameter

Scratching my head about this. In the rendered HTML for the code below, the btnEdit (in the GridView) has the correct Javascript in the onclick parameter (onclick="javascript:WebForm_DoPostBack..."). The btnAddNew has no onclick handler at all. Why? There is no compilation or runtime error, and the page uses a master page that has the Form tag..

<ContentTemplate>
<asp:ImageButton ID="btnAddNew" SkinID="btnAddNew" runat="server" 
    PostBackUrl='<%# "EditUser.aspx?action="+Constants.actionAdd %>' /> 
<asp:GridView ID="UserGridView" 
      runat="server" 
      DataKeyNames="UserId" 
      >  
      <Columns>
        <asp:TemplateField
              <ItemTemplate>
                  <asp:ImageButton id="btnEdit" SkinID="btnEdit" runat="server" 
                    PostBackUrl='<%# Eval("UserId", "EditUser.aspx?
                     action="+Constants.actionEdit+"&uid={0}") %>' />
              </ItemTemplate>
        </asp:TemplateField>                                        
      </Columns>          
</asp:GridView>

Upvotes: 1

Views: 12639

Answers (1)

Canavar
Canavar

Reputation: 48108

it looks like you don't need data binding tag (<%#) for the btnAddNew button. So you can assign this property at server side :

btnAddNew.PostBackUrl = "EditUser.aspx?action=" + Constants.actionAdd;

Upvotes: 4

Related Questions