2014-02-27 113 views
0

我正在使用asp.net mvc2。在页面加载显示javascript中的文本框中的值

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"]值。请给我的想法做这?

+0

这是ASP或ASP.NET?请在这里添加一个标签来表示对“<%...%>”负责的任何内容。 –

+0

我使用的是asp.net mvc ..我只想jquery – Duk

+0

你得到什么错误? – SivaRajini

回答

0

尝试

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

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