在后台获取前台按钮里的值(如LinkButton)

前台ASPX:

<asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>' onclick="LinkButton1_Click" runat="server" CssClass="dayifen">打一分</asp:LinkButton>


后台CS:

protected void LinkButton1_Click(object sender, EventArgs e)
    
{
        LinkButton btn 
= (LinkButton)sender;
        
int newsId = int.Parse(btn.CommandArgument);

        
if (NewsManager.AddScore(newsId))
        
{
            Response.Write(
"<script>alert(\"打分成功!\")</script>");
            NewsListBind();            
        }

        
else
        
{
            Response.Write(
"<script>alert(\"打分失败!\")</script>");
        }

    }

 

posted @ 2009-10-23 15:03  王翔(kingfly)  阅读(612)  评论(0编辑  收藏  举报