是在服务器端执行的代码?

时间:2022-02-20 03:50:06

I have Default.aspx page containing ASP.net tags code inside javascript as follows:

我的Default.aspx页面包含javascript中的ASP.net标记代码,如下所示:

<input id='send' text='submit' type='button' />

$('#send').click(function (){
    printable();
    return false ;
});
function printable(){
var html;
<% int X=10; %>
<% if( X <= 10) { %>
    html='<span> the value is less than or equal 10</span>';
<%}else{%>
    html='<span> the value is greater than 10</span>';
<%}%>
$(body).append(html) ;
}

My question is: Is when pressing send button that asp tags code gone to server side to execute?

我的问题是:当按下发送按钮时,asp标签代码去了服务器端执行?

2 个解决方案

#1


4  

No, what happens is that ASP.NET (or any server side language) will evaluate the page and will send to the browser raw HTML.

不,会发生什么是ASP.NET(或任何服务器端语言)将评估页面并将发送到浏览器原始HTML。

In your case, the browser will get this:

在您的情况下,浏览器将得到这个:

<input id='send' text='submit' type='button' />

$('#send').click(function (){
    printable();
    return false ;
});
function printable(){
    var html;
    html='<span> the value is less than or equal 10</span>';
    $(body).append(html) ;
}

#2


1  

The asp code is executed when you request the page and it will generate a JS code. So when you click on send it just execute the JS code that was generated by the server.

当您请求页面时,将执行asp代码,它将生成JS代码。因此,当您单击发送它时,只需执行服务器生成的JS代码。

#1


4  

No, what happens is that ASP.NET (or any server side language) will evaluate the page and will send to the browser raw HTML.

不,会发生什么是ASP.NET(或任何服务器端语言)将评估页面并将发送到浏览器原始HTML。

In your case, the browser will get this:

在您的情况下,浏览器将得到这个:

<input id='send' text='submit' type='button' />

$('#send').click(function (){
    printable();
    return false ;
});
function printable(){
    var html;
    html='<span> the value is less than or equal 10</span>';
    $(body).append(html) ;
}

#2


1  

The asp code is executed when you request the page and it will generate a JS code. So when you click on send it just execute the JS code that was generated by the server.

当您请求页面时,将执行asp代码,它将生成JS代码。因此,当您单击发送它时,只需执行服务器生成的JS代码。