0

I have to convert this code in Asp.Net C# codebehind

js function in the Silverlight code-behind MainPage.xaml.cs file, using the click event of a button.

private void btn_Click(object sender, RoutedEventArgs e)
{
   string DatabaseId = "99999999999999999999";
   string UserName = "user";
   string Password = "pass";

   HtmlPage.Window.Invoke("login", DatabaseId, UserName, Password);
}

1 Answer 1

0

I'm not well experienced on this, but based on answers to this question, you can try using ScriptManager.RegisterClientScriptBlock to invoke javascript function from ASP.NET code behind. Something like this :

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);
}

and another reference, a question on how to invoke script with parameters here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.