c# 4.0 - How to read <a></a> from Listview in asp.net -
i have listview have add in asp.net form there code below:
<asp:listview runat="server" id="listview2" groupitemcount="1" onitemdatabound="listview2_itemdatabound"> <layouttemplate> <asp:placeholder runat="server" id="groupplaceholder"/> </layouttemplate> <grouptemplate> <asp:placeholder runat="server" id="itemplaceholder"/> </grouptemplate> <itemtemplate> <div style="width: 200px; height: 220px; margin-left: 230px; margin-top: -220px"> <a href='<%# getafterburndownloadhref() %>'> <asp:image id="image2" runat="server" imageurl="images/download.jpg"/></a> <img src="images/downloadshadow.jpg"></div> </itemtemplate> <groupseparatortemplate> </groupseparatortemplate> <emptydatatemplate> </emptydatatemplate> </asp:listview>
there tage
<a href='<%# getafterburndownloadhref() %>'> <asp:image id="image2" runat="server" imageurl="images/download.jpg"/></a>
i have user type free user , paid user want change value in run time
fore payed user value take this
<a href='<%# getafterburndownloadhref() %>'> <asp:image id="image2" runat="server" imageurl="images/download.jpg"/></a>
and when free user loge , access page want add velue in tag show thing this
<a href='<%# getafterburndownloadhref() %>' name="popupmodal"> <asp:image id="image2" runat="server" imageurl="images/download.jpg"/></a>
this change want do. want know how can add name="popupmodal"
code in listview2_itemdatabound
protected void listview2_itemdatabound(object sender, listviewitemeventargs e) { image image2 = (image)e.item.findcontrol("image2"); //come code here <a></a> tag made change want string plantype = "free"; if (plantype == globals.planetype.planone) { //here want add name="popupmodal" in <a></a> //<a name="popupmodal"></a> image2.imageurl = "~/images/lockdownload.jpg"; } else { image2.imageurl = "~/images/download.jpg"; } }
any buddy have idea how can add this.
you can set anchor server side control , change it's attribute in code. markup may like:
<a id="popupmodal" runat="server" href='<%# getafterburndownloadhref() %>' > <asp:image id="image2" runat="server" imageurl="images/download.jpg"/> </a>
and in code behind:
protected void listview2_itemdatabound(object sender, listviewitemeventargs e) { image image2 = (image)e.item.findcontrol("image2"); //come code here <a></a> tag made change want string plantype = "free"; if (plantype == globals.planetype.planone) { htmlanchor popupmodal = (htmlanchor)e.item.findcontrol("popupmodal"); //here want add name="popupmodal" in <a></a> //<a name="popupmodal"></a> popupmodal.attributes.add("name", "popupmodal"); image2.imageurl = "~/images/lockdownload.jpg"; } else { image2.imageurl = "~/images/download.jpg"; } }
Comments
Post a Comment