Если Вы открыты для использования pywin32, можно использовать вызовы Win32 из Python. Это - то, что мы делаем в нашем веб-сервере CherryPy:
import win32security
token = win32security.LogonUser(
username,
domain,
password,
win32security.LOGON32_LOGON_NETWORK,
win32security.LOGON32_PROVIDER_DEFAULT)
authenticated = bool(token)
The warning is happening because the code block is inside a JavaScript block; the compiler is trying to be smart about recognizing the difference between HTML/controls and JavaScript.
Although it's a bit ugly, you should be able to eliminate the warning by using eval('<%= x %>')
You might also have a look at an article I wrote on using ASP.NET to create dynamic JavaScript: http://www.12titans.net/p/dynamic-javascript.aspx
Visual Studio is validating the HTML markup on the page. Strictly speaking, the '<' is not valid XHTML. This warning may be caused by a limitation of the validation as Visual Studio is interpreting the '<' character inside javascript as meaning 'less than'!
Obviously these inline expressions are not valid client code. One can change the HTML validation options in Tools|Options|Text Editor|HTML. Mind you, it may be better to simply ignore these warnings rather validate against HTML 4.01 or turn off the validation completely.
If all you're doing is adding javascript to your page, you could use RegisterClientScriptBlock to build the script server-side and then let it output it to the page.
This way you don't have to have any server-side scripting within your page and all the overhead that goes with that.
Если вы хотите быть абсолютно законными, используйте литерал:
<asp:Literal ID="litX" runat="server"></asp:Literal>
и установите его Текст
на все
блок на стороне сервера.
Я делал это раньше, и проблем не было. Однако я использую jQuery $ (document) .ready () вместо init (). Однако я не думаю, что это должно быть проблемой.
Какой тип данных - x? Если это строка, попробуйте заключить ее в одинарные кавычки, а если это число, используйте функцию синтаксического анализа для этого типа данных.
<script type="text/javascript" language="javascript">
var s;
var n;
function init()
{
s = '<%= x %>';
n = parseInt('<%= x %>');
eval('<%= x %>'); /* Raw Javascript */
}
</script>
Другой проблемой может быть уровень доступа к свойству. Веб-формы ASP.NET не могут получить доступ к закрытым полям непосредственно из кода программной части. Доступ должен быть защищенным или открытым.