I have a ListView i have add in asp.net form there is code is 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 is a tage that is this
<a href='<%# GetAFTERburnDownloadHRef() %>'>
<asp:Image ID="Image2" runat="server"
ImageUrl="images/Download.jpg"/></a>
I have to user type free user and paid user i want to change some value in run time
fore payed user value take will be this
<a href='<%# GetAFTERburnDownloadHRef() %>'>
<asp:Image ID="Image2" runat="server"
ImageUrl="images/Download.jpg"/></a>
and when free user loge and access the page then this i want the it will be add some velue in tag that will show some thing like this
<a href='<%# GetAFTERburnDownloadHRef() %>' name="popupmodal">
<asp:Image ID="Image2" runat="server"
ImageUrl="images/Download.jpg"/></a>
this change i want to do. i want to know how can i add name="popupmodal"
by code in ListView2_ItemDataBound
protected void ListView2_ItemDataBound(object sender, ListViewItemEventArgs e)
{
Image Image2 = (Image)e.Item.FindControl("Image2");
//come code here for get <a></a> tag to made this change I want
string PlanType = "free";
if (PlanType == Globals.PlaneType.PlanOne)
{
//here i want to add name="popupmodal" in <a></a> like this
//<a name="popupmodal"></a>
Image2.ImageUrl = "~/images/LockDownload.JPG";
}
else
{
Image2.ImageUrl = "~/images/Download.JPG";
}
}
any buddy have any idea how can i add do this.
You can set the anchor as server side control and change it's attribute in code. The markup may look 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 for get <a></a> tag to made this change I want
string PlanType = "free";
if (PlanType == Globals.PlaneType.PlanOne)
{
HtmlAnchor popupmodal = (HtmlAnchor)e.Item.FindControl("popupmodal");
//here i want to add name="popupmodal" in <a></a> like this
//<a name="popupmodal"></a>
popupmodal.Attributes.Add("name", "popupmodal");
Image2.ImageUrl = "~/images/LockDownload.JPG";
}
else
{
Image2.ImageUrl = "~/images/Download.JPG";
}
}