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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:44:27+00:00 2026-06-17T23:44:27+00:00

I have this aspx: <body> <div> <script type=text/javascript> function NewPage() { document.location.href = http://www.nextservice.pt/

  • 0

I have this aspx:

 <body>
    <div>
    <script type="text/javascript">
        function NewPage() {
            document.location.href = "http://www.nextservice.pt/"
        }
        </script>
         <form id="form1" runat="server">
 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

                    <asp:Button ID="Btn2" runat="server" Text="OK" onclick="Button2_Click" />

            CODE1: <asp:Label ID="Label1" runat="server" Text="Label" ForeColor="#CC0000" />
        </form>
        </div>
</body>

and I’m working with web forms, and I wont call this button on aspx.cs

   public partial class SITE_TESTER : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button2_Click (object sender, EventArgs e)
    {
        string code = TextBox1.Text.ToString();

        if (!verifyCode(code))  // comparing users from table 
        {
            Label1.Text = "Not Exists";  //for invalid code
        }
        else
        {
            Label1.Text = "Exist";  //for sucsseful code
            /*

            I Wont call my JavaScript Function here!!!!

            */
        }
    }
}
  • 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-17T23:44:28+00:00Added an answer on June 17, 2026 at 11:44 pm

    you can call a javascript method from server side in asp.net by following ways:

    protected void button_Click(object sender , EventArgs e)
    {
            string jsMethodName= = "NewPage()";
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "uniqueKey", jsMethodName, true);
    
          //or
          //ScriptManager.RegisterStartupScript(this, GetType(), "NewPage()", false); 
    }
    

    you can use either ScriptManager.RegisterStartupScript or ScriptManager.RegisterClientScriptBlock

    so difference between the two is explained below:

    Let’s say we have a .aspx page with the following form tag : (Line
    nos. are for reference)

    1. <form id="Form1" runat="server">
    2. ..
    3. ..
    4. ..
    5. </form>
    

    Now let’s look at key differences for each method :

    A.
    Page.RegisterClientScriptBlock() will insert the block of script
    before Line 2.
    Page.RegisterStartupScript() will insert the script after Line 4.

    B.
    Page.RegisterClientScriptBlock() should usually be used for scripts
    encapsulated in functions. (hence the word “block”)
    Page.RegisterStartupScript() can be used for any script, even if it’s
    not in a function.

    C.
    Page.RegisterClientScriptBlock() should be used for functions that
    don’t need to run on Page load.
    Page.RegisterStartupScript() should be used for scripts that must run
    on Page Load.

    D.
    Page.RegisterClientScriptBlock() should be used for a script that does
    not require the form elements to have been created.
    Page.RegisterStartupScript() should be used for scripts that require
    the form elements to have been created and uses references to them.

    Notice that all the 4 differences are essentially related to each
    other (they build upon the prev. one). The difference put in one line
    can sometimes be too subtle.

    you can know more about these from here and here

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

Sidebar

Related Questions

I have this function loadActivity() { $.ajax({ url: default.aspx?onemore=yes, dataType: 'json', context: document.body, type:
I have this in my ASPX page: <input id=MY_LAST_FOCUS name=MY_LAST_FOCUS type=text runat=server /> In
I have the following test ASPX page: <head runat=server> <title></title> <script src=js/jquery-1.2.6.min.js type=text/javascript></script> <script
I have this: <textarea name=content></textarea> and in javascript code in the same aspx file
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
Inside my .aspx I have some JSON code that looks like this: function someFunctionName()
I have javascript which sets the location of panel and javascript is below function
I have 2 DropDownList, like Master-Slave. This is my Default.aspx: <html xmlns=http://www.w3.org/1999/xhtml> <head runat=server>
I have this inside a usercontrol in my aspx: <asp:TextBox TextMode=MultiLine onkeydown=textCounterLatest('<%=txtContent.ClientID%>' , '<%=remLen.ClientID
I have two aspx pages: DashboardPreview.aspx: This is the homepage. It shows top 5

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.