Solved

issues running javascript and Protected Sub Submit_Click

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now