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 6681253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:34:08+00:00 2026-05-26T04:34:08+00:00

in code behind : string func = showSuccessMessage(+name+);; ClientScript.RegisterStartupScript(this.GetType(), success, func, true); in a

  • 0

in code behind :

    string func = "showSuccessMessage("+name+");";
    ClientScript.RegisterStartupScript(this.GetType(), "success", func, true);

in a js file :

   function showSuccessMessage(user)
   {
        $("#box").dialog({
            title:"User Registration",
            html: user.toString() + " Successfully Registered", 
            modal: true,
            buttons: {
                   Ok: function () {
                    $(this).dialog("close");
                    var s = "../Pages/main.aspx";                
                    window.location = s;
                   }
        }
   });
 } // end function 

when i try to pass the func string with no arguments every thing works out fine

when i try to append the argument into the function string i get an error from the browser

Uncaught ReferenceError: john is not defined

(john being the value of name)
now i’m guessing the problem occurs because the way the function is registered it can’t distinguish between a the variable and the value , so it is a non-defined type john

so the question stands :

how does one send arguments to a javascript function from code-behind

thanks in advance
eran.

btw similar question :
showing something similar to what iv’e attempted

similar question

  • 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-26T04:34:09+00:00Added an answer on May 26, 2026 at 4:34 am

    The way you are writing it, it’s like passing in john as a variable, not a string. It’s like invoking

    showSuccessMessage(john); // what you're doing in js
    showSuccessMessage('john'); // what you need
    

    Correct that with

    string func = "showSuccessMessage('"+name+"');"; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using page.registerstartupscript in my code behind C#. Its like this: string item1=category1;
I have this code in my code-behind file of my View: private string GetSelectedSchoolclassCode()
I made a function to truncate a string in the code behind file. But
Code Behind: [WebMethod] public static string emp() { return BlaBla; } Aspx Page: $(document).ready(function()
In code-behind of an ASP.NET page I have this method: public string TestFunc() {
My code-behind looks like this class Image { public string tnImg { get; set;
In code behind for a page: Messenger.Default.Register(this, CheckWaitState); and private void CheckWaitState(string message) {
I've been injecting this jQuery code from the code behind of a .net user
I have a public string in my code behind file that I intend to
In my code behind page, how do I access the connection string which is

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.