如何计算图像上的点击次数?!! [英] How Can I Count The No.Of Clicks On An Image?!!

查看:62
本文介绍了如何计算图像上的点击次数?!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在尝试显示计数时遇到错误,没有点击图像的次数。

请帮助我......我刚接触.net,我不知道。我的代码是



源代码:

Hi,
Im getting an error, when trying to display the count, that no.of times an image is clicked.
Please help me... As im new to .net, i am not getting any idea. My code is

Source Code:

<asp:Repeater ID="RepDetails" runat="server" onitemcommand="RepDetails_ItemCommand">
<HeaderTemplate>
<table style=" border:1px solid #df5015; width:500px" cellpadding="0">
<tr style="background-color:#00CC66; color:White">
<td colspan="1" align="center">
<b>Comments</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color:#00CC66">
<td>
<table style="background-color:#EBEFF0;border-top:1px dotted #df5015; width:500px; border-top-color: #009900;" >
</table>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblComment" runat="server" Text='<%#Eval("Comment") %>'/>
</td>
</tr>
<tr>
<td>
<table style="border-top:1px dotted #df5015;border-bottom:1px solid #df5015; width:500px; border-color: #00CC66 #008000 #00CC66 #008000;" >
<tr>
<td><asp:ImageButton ID="imgbtnlike" runat="server" ImageUrl="~/image/like.png" Height="20" Width="20" CommandName="imgbtnlike"/>&nbsp;<asp:Label ID="lblcount" runat="server" ></asp:Label><asp:Label ID="lbllike" runat="server" text="Likes"></asp:Label></td>
<td>Event: <asp:Label ID="lblUser" runat="server" Font-Bold="true" Text='<%#Eval("EvenConvID") %>'/></td>
<td>Created Date:<asp:Label ID="lblDate" runat="server" Font-Bold="true" Text='<%#Eval("DateTime") %>'/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>







CodeView:




CodeView:

protected void RepDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
   {
       ImageButton imglike = sender as ImageButton;
       Repeater RepDetail1 = (Repeater)imglike.NamingContainer;
       Label lbllike = (Label)RepDetails.FindControl("lblcount");
       lblcount.Text = (lbllike.Text)Convert.ToInt32t;
       try
       {
           con.Open();
           SqlCommand cmd = new SqlCommand("usp_likecount", con);
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Connection = con;
           cmd.Parameters.AddWithValue("@EvenConvID", lblID.Text);
           DataSet ds = new DataSet();
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           da.Fill(ds);
           RepDetails.DataSource = ds;
           RepDetails.DataBind();

       }
       catch (Exception ex)
       {
           lblerror.Text = ex.Message;
       }

       con.Close();

   }





这里我收到错误As:



Here Im getting an error As:

Quote:

编译错误消息:CS0103:当前上下文中不存在名称'lblcount'



来源错误:





第70行:Repeater RepDetail1 =(Repeater)imglike.NamingContainer;

第71行:标签lbllike =(标签)RepDetails.FindControl(lblcount);

第72行:lblcount.Text =(lbllike.Text)Convert.ToInt32t;

第73行:尝试

第74行:{

Compiler Error Message: CS0103: The name 'lblcount' does not exist in the current context

Source Error:


Line 70: Repeater RepDetail1 = (Repeater)imglike.NamingContainer;
Line 71: Label lbllike = (Label)RepDetails.FindControl("lblcount");
Line 72: lblcount.Text = (lbllike.Text)Convert.ToInt32t;
Line 73: try
Line 74: {







请帮我把它搞定

先谢谢。




please help me to get it over
Thanks in Advance.

推荐答案

试试这个..



标签lbl = e.Item.FindControl(lblcount)作为标签;
try this..

Label lbl = e.Item.FindControl("lblcount") as Label;


这篇关于如何计算图像上的点击次数?!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆