Solved

issues running javascript and Protected Sub Submit_Click

Posted on 2011-09-18
2
212 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
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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

825 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