?
Solved

issues running javascript and Protected Sub Submit_Click

Posted on 2011-09-18
2
Medium Priority
?
217 Views
Last Modified: 2012-06-27
Hey guys,,,

i use the below javascript on my button:
<script type="text/javascript" >
    $(function () {
        $(".submit,#submit").click(function () {
            var comment = $("#textbox").val();
            var dataString = '&comment=' + comment;
            if (comment == '') {
                alert('Please Give Valid Details');
            }
            else {
                $("#flash").show();
                $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" />Loading Comment...');
                $.ajax({
                    async: false,
                    type: "POST",
                    url: "Default2.aspx",
                    data: dataString,
                    cache: false,
                    success: function (html) {
                        $("div#update").append(html);
                        $("div#update li:last").fadeIn("slow");
                        $("#flash").hide();
                    }
                });
            } return false;
        });
    });

    </script>

Open in new window



this works fine but it seems to cancel out the button so i am unablke to do button click commands in the code behind...

Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click
        Label1.Text = "hello"
        '  wall.addpost(textbox.Text)
        textbox.Text = ""
    End Sub

Open in new window


it seems to stop at the javascript and not perfrom submit_click??

any ideas why and how to solve it?
0
Comment
Question by:runnerjp2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36570065
>return false;
Try changing that to true.
0
 
LVL 22

Accepted Solution

by:
Mrunal earned 2000 total points
ID: 36572931
Surely it will not fire codebhind event as you are returning false in jabascript client side function on button click.
If you return true this will fire server side button click function also.

But if you only want to set the value to label and clear textbox then same thing you can also do at client side function. so no need to call server side button click function.

hope this clears you.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question