<asp:Label ID="answer1" runat="server" Text="Label" CssClass="option" Width="120">
<div class="div_chn"><asp:Label ID="chinese" runat="server" Text=""></asp:Label></div>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
         answer1.Attributes.Add("onclick", "choiceAnswer(this)");//选择传值
         }
     }function choiceAnswer(obj)
{
    $yourChoice=$(obj).text();
    $(".div_chn",$(obj).parent().parent()).text($yourChoice);
}Label chinese = e.FindControl("chinese") as Label;
我用jquery让点击answer1时,chinese的值被赋值answer1的值,运行时页面显示正常,但是提交时,没有值,再次调试,监视chinese 的值为空,请问这是为什么?该怎么办

解决方案 »

  1.   

    pageload里是否加
    if(!ispostback)
    {}
      

  2.   

    chinese是asp控件啊,需要这样取吗
      

  3.   

     可以用clientScript对象 调用前台方法 然后将值赋为空
      

  4.   

    clientScript?能详细点吗,没用过
      

  5.   

    赋值之后放入一个HiddenField  后台直接取HiddenField的Value
      

  6.   

    没有重新赋值吧,我有if(!ispostback)
      

  7.   

      answer1.Attributes.Add("onclick", "choiceAnswer(this)");//选择传值  干嘛不直接在前台answer1添加onclick事件。。事件掉用choiceAnswer()
    function choiceAnswer(obj) 

        $yourChoice=$(obj).text(); 
        $(".div_chn",$(obj).parent().parent()).text($yourChoice); 
         将值赋给HiddenField 
      

  8.   

    不可以直接获取
    可以通过ajax 或者hidden控件来实现