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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:42:43+00:00 2026-06-09T09:42:43+00:00

So what i have is a web application that uses c# code and javascript

  • 0

So what i have is a web application that uses c# code and javascript code. My javascript code generates some information dependant on the users input. Once this is finished it is saved using a ASP button. Attached to the asp button is a on client click and a on click event. the Javascript code validates the code and makes sure that the string that has been created is valid. If not a error message is sent to a hidden label. The C# code then checks that label and if it is empty (if there was no problem with validation) it executes the C# code. If it has a value inside then the error message from the hidden label is passed to a visible label using the c# code and shown to the user.

However if the error message is shown the page in automatically reloaded (as it is a button click event this always happens). and the users inputs are cleared from the screen.

Is there any way i can stop the page from reloading when the error message is shown?

CODE

Javascript:

    if (goalnum > 0 && blocknum > 0 && playernum == 1 && goalnum == blocknum) {


        mapsave = JSON.stringify(map);
        document.getElementById('<%=mapsave.ClientID %>').value = mapsave;

    }
    else {
        document.getElementById('<%=lblError.ClientID %>').value = "Your map must have one and only one player, one or more blocks, one or more goals and the number of blocks must match up with the number of goals";
    }

C#

protected void btnSave_Click(object sender, EventArgs e)
    {
        if (mapsave.Value.ToString() == "")
        {
            lblResult.Text = lblError.Value;
        }
        else
        {
            AddNodeToXMLFile("filepath.xml", "TileMaps");
        }

    }
  • 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-09T09:42:45+00:00Added an answer on June 9, 2026 at 9:42 am

    Do you return false on the button click? If not, even if validation has failed a new Post will fire.

    Can you post the code perhaps?

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

Sidebar

Related Questions

I have a web application that uses TONS of javascript, and as usual, there
I have a web application that uses two databases. DB1 Users perform their CRUD
I have a web application that uses a library which resides in TOMCAT_HOME/common/lib. This
I have never written any code that uses threads. I have a web application
I have a web application that uses RESTful url patterns. Currently if a users
Is this possible? I have a web application the uses EF code-first and SQL
I hope this makes sense. I have a ASP.NET web application that uses Entity
I have a REST-style web application that uses EF code first. I'm using AutoMapper
I have a web application that uses fixed css width. (1280px). With jquery, I
I have a web application that uses AzMan authorization to grant different functionality to

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.