Solved

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

Posted on 2013-01-10
4
472 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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 …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

707 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