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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:23:09+00:00 2026-05-18T09:23:09+00:00

I just found a funny behaviour in asp.net. I have a form that has

  • 0

I just found a funny behaviour in asp.net.

I have a form that has got a fieldset which is hidden when initially loaded and a submit button.

What I’m expecting to do is that when a user clicks the submit button, the fieldset would appear. The thing is, when I try to click the submit button, it will show the fieldset element but would dissaper immediately.

Would it be possible if you could point me in the right direction as to where in my code am I doing something wrong? See my code below.

Thanks a million!

Cheers,
Ann

<%@ Page Language="C#" AutoEventWireup="true" Inherits="JavascriptTest._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test Javascript</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.js"></script>
    <script type="text/C#" runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            var btnSubmit = '#<%= btnSubmit.ClientID %>';
            $('#result').hide();
            $(btnSubmit).click(function () {
                $('#result').show();
                return true;
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <fieldset id="result">
            <legend>Search Result</legend>
            <p>Cras risus. Parturient lectus! Ac quis. Enim arcu adipiscing nunc? Porta magna ultrices elit amet, turpis vel nunc, massa pulvinar sit, pulvinar amet elementum tristique diam parturient, eu in dolor, non pulvinar nisi, penatibus? Velit tincidunt? Pulvinar nec urna ac, pulvinar purus integer phasellus, ridiculus non dictumst penatibus dolor rhoncus elementum pellentesque? Adipiscing et, dapibus, amet ac porta! Magna tristique, sed porta elit mid. Et ultricies et elit mattis. Arcu! Elementum ac? Nisi turpis, vel in massa pellentesque porta lectus, egestas aenean scelerisque risus? Placerat purus cum et. Egestas sociis, adipiscing porttitor scelerisque integer? Auctor a arcu sit aliquam amet sed odio, velit turpis, risus, porttitor mid diam, ac arcu lectus auctor, facilisis tincidunt! Et, proin, turpis nunc velit? Elementum.</p>
        </fieldset>

        <asp:Button ID="btnSubmit" runat="server"  Text="Submit" />
    </div>
    </form>
</body>
</html>
  • 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-18T09:23:09+00:00Added an answer on May 18, 2026 at 9:23 am

    The default button behavior is kicking in here, causing the <form> to submit and your page to refresh (hiding the <fieldset> again). You need to prevent that default behavior with event.preventDefault() or return false, like this:

    $(document).ready(function () {
        var btnSubmit = '#<%= btnSubmit.ClientID %>';
        $('#result').hide();
        $(btnSubmit).click(function (e) {
            $('#result').show();
            e.preventDefault();
        });
    });
    

    event.preventDefault() will just prevent the submission where as return false will kill the event dead in its tracks…so I really consider return false overkill here. It’s really better to do what you’re trying to do, not more than that which can cause potential unwanted issues later (for example a .live()/.delegate() handler wouldn’t work if you killed the event, etc).

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

Sidebar

Related Questions

I just found out about superfish and currently using it on an asp.net. The
Just found out that the video output of the iPad is not a system
I just found myself creating a class called InstructionBuilderFactoryMapFactory. That's 4 pattern suffixes on
I just found out that by converting PNG32 to PNG8 via Photoshop will fix
I just found out that my program is losing 5% execution speed when it
I just found Dean Edwards javascript packer here: http://dean.edwards.name/packer/ It has a couple of
I just found the wonderful ElasticFox , a Firefox plugin that makes working with
I have this funny issue. I know this error message is found in a
Just found that unfinished manual, but it's really unfineshed. Right on the climax. I
I have made a mod_rewrite condition that will just add a parameter to the

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.