页面加载在javascript中显示文本框中的值

时间:2014-02-27 08:50:45

标签: javascript jquery asp.net-mvc input

我正在使用asp.net mvc2。

Javascript代码:

$(document).ready(function () {
          $("#candidatecontact").hide();              
          document.getElementById("counting").value =  '<%=ViewData["ResumesCount"] %>';
            $('#butt2').click(function () 
            {
                 count();
            });
        });    

function count() {               
             var tempId = <%=Model.Id%>; 
             var url = '/Page/Count';
             $.ajax({
                    type: "GET",
                    url: url,
                    data: { id : tempId}, 
                    dataType: "int",
                    success : function (count) {                            
                        SetCount(count);                            
                    }
                });                                     
        }

HTML代码:

<% ViewData["ResumesCount"] = remainingHorsCount; %>
<input id = "counting" type = "text" style="width:20px;"/>

当上面文本框中的页面加载显示ViewData["ResumesCount"]的值时..请告诉我这样做的想法?

1 个答案:

答案 0 :(得分:0)

尝试

<input id = "counting" type = "text" value="<%= remainingHorsCount%>" style="width:20px;"/>

<input id = "counting" type = "text" value="<%= ViewData['ResumesCount']%>" style="width:20px;"/>