我必须在Asp.Net C#codebehind
中转换此代码使用按钮的单击事件在Silverlight代码隐藏的MainPage.xaml.cs文件中运行js函数。
private void btn_Click(object sender, RoutedEventArgs e)
{
string DatabaseId = "99999999999999999999";
string UserName = "user";
string Password = "pass";
HtmlPage.Window.Invoke("login", DatabaseId, UserName, Password);
}
答案 0 :(得分:0)
我对此并不熟悉,但根据this question的答案,您可以尝试使用ScriptManager.RegisterClientScriptBlock从后面的ASP.NET代码调用javascript函数。像这样:
private void btn_Click(object sender, RoutedEventArgs e)
{
string DatabaseId = "99999999999999999999";
string UserName = "user";
string Password = "pass";
string script = string.Format("login({0}, {1}, {2});", DatabaseId, UserName, Password);
ScriptManager
.RegisterClientScriptBlock(this, typeof(System.Web.UI.Page), "login", script, true);
}
和另一个参考,关于如何使用参数here
调用脚本的问题