im trying to enable a button that is disabled within an itemTemplate, if theres a session then the button will be enabled. however i cannot access the button object in the code-behind file.

HTML CODE
----------

<div id="gal_wrap">
   <asp:ListView ID="ListView1" runat="server" EnableModelValidation="false" OnPagePropertiesChanging="listItems_PagePropertiesChanging">
            <LayoutTemplate>
                    <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
            </LayoutTemplate>
       
            <ItemTemplate> 
              <ul class="thumbnails gallery">
                <li class="gallery">
                       <a style="text-decoration:none;" href="#">
                          <img alt="<%#Eval("gallery_name") %>" style="border:0px;" src="photo_load.aspx?gallery_id=<%#Eval("gallery_id") %>&thumbnail=1" />
                          <span class="below-image"><%#Eval("gallery_name") %></span>
                          <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Visible="false" Text="Button" />                   
                       </a>               
                </li>
              </ul>
            </ItemTemplate>
        </asp:ListView>

CODEBEHIND FILE
---------------

public void Page_Load(object sender, EventArgs e)
        {
            if (Session["x"] != null) //if the user is logged in
            {
                Button1.visable = "true";
            }
        }

Thanks for your help

Recommended Answers

All 2 Replies

thanks for that, this has helped.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.