Solved

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

Posted on 2013-01-10
4
455 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

708 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

13 Experts available now in Live!

Get 1:1 Help Now