Solved

issues running javascript and Protected Sub Submit_Click

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

21 Experts available now in Live!

Get 1:1 Help Now