解决方案 »

  1.   

    用@Html.TextBoxFor(m=>m.Property, new {@onfocus="alert(123);"})
      

  2.   

    1L的方法看上去可以。你贴出客户端html源代码的相关片段。
      

  3.   


    @Html.TextBoxFor(m >= m.qyName, New {@onfocus="alert(123);"}) 我这样写提示 我m 是保护级别,New 的东西也无效.........
      

  4.   

    @Html.TextBoxFor(Function(m) m.qyName, New With {.onfocus="alert(123);"}) 
      

  5.   

    不用jquery吗?$( "#target" ).focus(function() {
      alert( "Handler for .focus() called." );
    });
      

  6.   


    楼主你又救我一命,我之前写成了 @Html.TextBoxFor(m => m.qyName, New With {.onfocus="alert(123);"})
    现在是
    @Html.TextBoxFor(Function(model) model.qyDate, New With {.onfocus = "WdatePicker();"})对这个HtmlHelper好不熟悉,才刚学几天,昨天在MVC中把增删改用弹出层实现了,然后就在纠结日期控件,后续把分页写好就基本完成任务了。谢谢版主~
      

  7.   


     企业名称: @Html.TextBox("qyname", "", New With {.style = " width:120px;"})
      合同号:     @Html.TextBox("ContractNo", "", New With {.style = " width:80px;"})
      签约日期:   @Html.TextBox("qydate", "", New With {.style = " width:80px;", .onfocus = "WdatePicker();"})
      到账日期:   @Html.TextBox("todate", "", New With {.style = " width:80px;", .onfocus = "WdatePicker();"})
      截止日期:   @Html.TextBox("enddate", "", New With {.style = " width:80px;", .onfocus = "WdatePicker();"})
      顾问:      @Html.TextBox("counselor", "", New With {.style = " width:80px;"})
    版主 我要做查询,控制器如何能获取到这些值并查询了?
            Function Index() As ActionResult
                Dim dal As New HRContractDAL
                Dim dt As New DataTable
                Dim strWhere As String = " 1=1 "
                If Request.Form("qyname") <> "" Then
                    strWhere = strWhere + " and qyname like '" + Request.Form("qyname") + "%'"
                End If
                If Request.Form("ContractNo") <> "" Then
                    strWhere = strWhere + " and ContractNo like '" + Request.Form("ContractNo") + "%'"
                End If
                If Request.Form("qydate") <> "" Then
                    strWhere = strWhere + " and qydate >= '" + Request.Form("ContractNo") + "%'"
                End If
                If Request.Form("todate") <> "" Then
                    strWhere = strWhere + " and todate >= '" + Request.Form("ContractNo") + "%'"
                End If
                If Request.Form("enddate") <> "" Then
                    strWhere = strWhere + " and enddate <= '" + Request.Form("ContractNo") + "%'"
                End If
                If Request.Form("counselor") <> "" Then
                    strWhere = strWhere + " and ContractNo like '" + Request.Form("ContractNo") + "%'"
                End If
                dt = dal.GetList(strWhere, "")
                Dim list As New List(Of HRContractEntity)
                For Each row As DataRow In dt.Rows
                    list.Add(New HRContractEntity With {.ID = row("ID").ToString(), .qyName = row("qyName").ToString(), .ContractNO = row("ContractNO").ToString(), .counselor = row("counselor").ToString(), .endDate = row("endDate").ToString(), .logoMoney = row("logoMoney").ToString(), .phone = row("phone").ToString(), .qyDate = row("qyDate").ToString(), .qyMoney = row("qyMoney").ToString(), .toDate = row("toDate").ToString()})
                Next
                Return View(list)
            End Function
     查询我是这样写的, 断点调试发现获取不到值