隐藏table以及对象赋值

View Code
 <tbody class="replay_msg"   <%=LeaderMailObj.处理人 == "" ? "style='display:none'":"style='display:block'" %> >     
           <tr>
               <td class="th1b">回复</td>
           </tr>
            <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">          
                <tr>
                  <td valign="top" width="15%" class="td5b">回复内容:</td>
                  <td class="td6b"><asp:TextBox ID="txtreply" runat="server" class="mailbox_input4"  TextMode="MultiLine"></asp:TextBox></td>
                </tr>      
              
                 <tr>
                  <td class="td5"> 处理时间:</td>
                  <td class="td6"> <%=Cbw_SinopecPortal_WebPart.CoolFuncs.DateTime2Str(LeaderMailObj.处理时间, "yyyy-MM-dd HH:mm:ss") == "0001-01-01 00:00:00" ? "尚未处理" : Cbw_SinopecPortal_WebPart.CoolFuncs.DateTime2Str(LeaderMailObj.处理时间, "yyyy-MM-dd HH:mm:ss")%></td>  
                 </tr>
                 <tr>
                  <td class="td5"> 处理人:</td>
                  <td class="td6"> <%=LeaderMailObj.处理人 == "" ? "尚未处理" : LeaderMailObj.处理人%></td>
                 </tr>
                 
              </table></td>
          </tr>
       
         
       </tbody>
          </table>
        
      </div>
      <div class="mailbox_reply">
               <asp:Button ID="btnDel" runat="server" Text="删除回复"  class="mailbox_btn2" 
                      onclick="btnDel_Click"/> 
                 <asp:Button ID="btnOnLine" runat="server" Text="线上回复"  class="mailbox_btn2" 
                      onclick="btnOnLine_Click" OnClientClick="return checkReplay();"/>
                 <asp:Button ID="btnOutLine" runat="server" Text="线下回复"  class="mailbox_btn2" 
                      onclick="btnOutLine_Click" OnClientClick="return confirm('确定线下回复吗?');"/>
            </div>

在table前面加个 <tbody class="replay_msg"   <%=LeaderMailObj.处理人 == "" ? "style='display:none'":"style='display:block'" %> >
强类型赋值:

public table LeaderMailObj = new table();
var allmail = LeaderMail.Where(item => item.ID == queryID);
            LeaderMailObj = allmail.Count() > 0 ? allmail.FirstOrDefault() : new 领导信箱();

取得值后在前台就可以直接<%=LeaderMailObj.处理人%> 直接赋值,这种方法需要注意防止对象为空的情况;

<asp:Button ID="btnOnLine" runat="server" Text="线上回复"  class="mailbox_btn2" 
                      onclick="btnOnLine_Click" OnClientClick="return checkReplay();"/>

OnClientClick调用js的方法

<script type="text/javascript">
   function checkReplay(){
      $(".replay_msg").show(); 
      if($(".mailbox_input4")[0].value==""){
           return false;
      }else{
         return confirm('是否提交');        
      }
     return false; 
   }
 
</script>

点击把table显示出来,框里没有内容,则不给提交return false;框里有内容则return confirm('是否提交')

 

 

posted @ 2012-09-25 11:31  double_ed  Views(242)  Comments(0Edit  收藏  举报