Solved

Javascript to raise an form click event, asp.net 3.5 C# , VS 2010

Posted on 2013-01-10
4
461 Views
Last Modified: 2013-02-13
Hi,

When i click Server control "Save" button ...

using JavaScript, i want to generate an event as if i clicked on form area (not on any control in the form) before execution of the "save: button code.

Thanks
0
Comment
Question by:kishan66
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 38763620
can you elaborate your question?
when exactly do you want to generate a click event on client side?
0
 

Author Comment

by:kishan66
ID: 38763684
hi sedgwick,

Assume i enter some thing in a textbox (control within form) ....my focus is still in textbox.
now when i click on "Save" button (which is in a ribbon control).. using javascript, i want to loose focus of that textbox (inthis example) and then submit the form.

Problem : when my focus is still in textbox , even if i click save the changed text value is not retained  when the form is submitted.

works fine when i click on anyother control or any where else on form.
0
 
LVL 18

Assisted Solution

by:Rajar Ahmed
Rajar Ahmed earned 250 total points
ID: 38763730
Are you lookin like this , ?
<!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></title>
    <script>
        function validate() {
            if (document.getElementById("TextBox1").value == "") {
                alert("Please Enter Name");
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Name :<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br />
        <asp:Button ID="Button1" runat="server" Text="Button" 
            OnClientClick="return validate();" onclick="Button1_Click" />

    </div>
    </form>
</body>
</html>

Open in new window


   protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write("Hi" + TextBox1.Text);
    }

Open in new window

0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 38763749
Hi kishan66,

skip my previous comment .
Post the code which can show your issue .
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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 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

17 Experts available now in Live!

Get 1:1 Help Now