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

  • Home
  • SEARCH
  • 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 8152021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:35:13+00:00 2026-06-06T15:35:13+00:00

hello i am using this Page.ClientScript.RegisterStartupScript() to call a javascript function from vb code

  • 0

hello i am using this Page.ClientScript.RegisterStartupScript() to call a javascript function from vb code behind , and this works fine with me My question is how can i send variables from the code behind to the javascript function here is what i have tried so far :

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
   Handles Me.LoadComplete
    Dim Myname As String = "myName"
    Dim cstype As Type = Me.GetType()
    Page.ClientScript.RegisterStartupScript(cstype, "MyKey", "hello(Myname);",
  True)

End Sub 

javascript :

   <script type="text/javascript">
    function hello(name) {
        alert("hello world from javascript " + name)
    }
</script>

Thank you …

  • 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-06-06T15:35:15+00:00Added an answer on June 6, 2026 at 3:35 pm

    You have to use correct quotations to pass strings:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
       Handles Me.LoadComplete
        Dim Myname As String = "myName"
        Dim cstype As Type = Me.GetType()
        Page.ClientScript.RegisterStartupScript(cstype, "MyKey", "hello('" & Myname & "');",
      True)
    
    End Sub 
    

    Note single quotes around variable name.

    Another way for bi-directional passing of data between client and server-side code is hidden fields, e.g

    <asp:HiddenField ID="xhidMyname" runat="server" />
    

    or

    <input type="hidden" id="xhidMyname" runat="server" />
    

    This field will be accessible both client-side and server side via it’s “value” property.

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

Sidebar

Related Questions

I am displaying a message in my ASP.NET from code-behind using this: Response.Write(<script>alert('Hello')</script>); When
hello every one i am using this code to give glowing effect to my
Hello I am using Code::Blocks in Windows XP. When I am running this program
Hello i am having this problem: i am downloading data from xml using linq
Consider this code: #include <iostream> using namespace std; class hello{ public: void f(){ cout<<f<<endl;
hello i'm using this example http://lexandera.com/2009/01/extracting-html-from-a-webview/ to get the HTML from a webview. But
I have been using this rule: RewriteRule ^([^\.]+)/?$ index.php?page=$1 [L] Which will turn example.com/page/hello
hello all i am using this code to show flip animation...... i have a
Hello can anyone help? I am using this full page slider.. http://www.musca.se/full-window-width-jquery-tools-content-slider-demo/ However i
Hello every I want to pass a message from php to JavaScript function and

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.