Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7442971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:15:29+00:00 2026-05-29T11:15:29+00:00

I am trying to have a simple block of JS code call my Silverlight

  • 0

I am trying to have a simple block of JS code call my Silverlight control via the HTML Bridge. All of the dozen or so samples I have read ALL show using a HTML button with a wired up JS function on the click like so:

<input id="Button1" type="button" value="Test Call To SL" onclick="return CallSilverlight()" />

function CallSilverlight() {

    var SLControl = document.getElementById("MySLControl");
    SLControl.Content.Page.UpdateText("Hello from Javascript!");
} 

The above works perfectly. The JS function ‘CallSilverlight’ is called and a Silverlight method I have is called. OK in my scenario I need to press an ASP.NET Server Control button, do some processing and then have the JS function called. Easy enough, in the finally block of the ASP.NET button click event I register the JS function: CallSilverlight() and indeed it does get called (breakpoint works). However I always get an “unknown exception” message from the debugger when making the call to the Silverlight method and that’s it!

I assume the PostBack is causing issue because that’s the main difference between the HTML button and the ASP.NET one. Is there any problem with using an ASP.NET button and then calling the JS as I have, and if not what might I be doing incorrectly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:15:30+00:00Added an answer on May 29, 2026 at 11:15 am

    Once again figured this out quite soon after posting the question – ASP.NET server controls (i.e. Buttons) can be used. However, the client side events must be used to call the JS function that calls the Silverlight scriptable methods rather than trying to register JS on a PostBack. So the button needs to look like the following:

    <asp:Button ID="Button1" runat="server" Text="Test Call To SL" OnClientClick="return CallSilverlight()" />
    

    Button.OnClientClick Property:
    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.onclientclick.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple html block like: <span id=replies>8</span> Using jquery I'm trying to
I'm trying to have a simple html table, that highlights a row as a
I have a (simple) sitemap and am trying to figure out why a certain
I have a simple WPF application which I am trying to start. I am
I have a simple Class Hierarchy that I am trying to get to work
I have a simple windows service application I am trying to debug in VS
I have a simple rails 2.3.4 application I am trying to get running with
i have a simple xml file in a wcf service that i am trying
I have a simple question. I am trying to design a simple Android app,
I have a simple question concerning Javascript. I am trying to print in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.