Solved

detect Control Changed (Get Dirty?) for any control on an asp.net 2.0 page

Posted on 2006-11-16
4
324 Views
Last Modified: 2011-10-03
Just looking for a simple way to detect that any control on a web page has been changed, or even clicked into, so I can clear a message etc when the next operation is beginning. i.e the page says thank you for saving, then user wants to start a new record, I want to detect this and clear or change the message.

Thanks
0
Comment
Question by:balone351
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:ethoths
ID: 17956387
It's all client side javascript...

<html>
      <head>
            <script language="javascript">
                  function setMessage()
                  {
                         document.getElementById("Message").innerText="You are entering new data!!!!"
                  }
            </script>
      </head>
      <body>
            <input type="text" onclick="javascript:setMessage()">
            <div id="Message">Message</div>
      </body>
</html>
0
 

Author Comment

by:balone351
ID: 17986596
sorry, not up with java, using asp.net2?
0
 
LVL 11

Accepted Solution

by:
ethoths earned 500 total points
ID: 17986644
If you want it client side it'll have to be JavaSCRIPT. The previous code actually works. Just cut and paste it into a page and you'll be able to see how it works. If you want to know when a user "or even clicked into" a control like a text box then you'll HAVE to do this.

You can do some of the other things using postbacks but that's a lot of work and a huge roundtrip just to change a message.

Remember, there is nothing wrong with using javascript on an asp.net page. Javascript is the only cross brower programming technology that works on the client. In fact ASP.NET renders a lot of javascript to the page automatically in certain circumstances. If you're going to be an ASP.Net developer then you'll have to at least have an appreciation of javascript.



0
 

Author Comment

by:balone351
ID: 17987032
Thanks for pushing me ethoths, I am keen to get it right, and would love to get a handle on javascript, just so much to learn already moving to .net!! Really appreciate your time

I've tried to add your code to the page, but keep tripping over. below is the page i have that it needs to be added to, if you could help me with this i can run with it in other areas. I am using a master page, would that make a difference? the page has a content place holder in it which changes the html a bit.

Sorry, on a steep learning curve here, i thought this one was easy

Here's the page:

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Booking.aspx.vb" Inherits="Home" title="Clickmow Bookings" %>

<%@ Register Assembly="GMDatePicker" Namespace="GrayMatterSoft" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
   
    <span >
        Please fill in the following to order any services you require<br />
        and we will contact you as soon as possible.
        <br /><br />
    </span>
   
    <div>
        <table style="text-align: right;">
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="Label16" runat="server">Preferred Date:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <cc1:GMDatePicker ID="GMDatePicker1" runat="server" CalendarFont-Names="Arial" InitialText="Select a Date">
                            <CalendarDayStyle Font-Size="9pt" />
                            <CalendarTodayDayStyle BorderWidth="1" BorderColor="darkred" Font-Bold="true" />
                            <CalendarOtherMonthDayStyle BackColor="whitesmoke" />
                            <CalendarTitleStyle BackColor="#E0E0E0" Font-Names="Arial" Font-Size="9pt" />
                      </cc1:GMDatePicker><br />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblWork" runat="server">What would you like done?</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox skinID="TextBoxMultiLine" ID="txtWork" runat="server" TextMode="MultiLine"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblDiscountCode" runat="server">Discount Code:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtDiscountCode" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblFirstName" runat="server">First Name:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblLastName" runat="server">Last Name:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblHomePhone" runat="server">Home Phone:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtHomePhone" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblMobile" runat="server">Mobile:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblEmail" runat="server">Email:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblStreetNumber" runat="server">Street Number:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtStreetNumber" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblStreetName" runat="server">StreetName:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtStreetName" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblSuburb" runat="server">Suburb:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtSuburb" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblPostCode" runat="server">PostCode:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtPostCode" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblExtraDetails" runat="server">Extra Details:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox skinID="TextBoxMultiLine" ID="txtExtraDetails" runat="server" TextMode="MultiLine"></asp:TextBox>
                </td>
            </tr>
        </table>
        <asp:Label ID="lblThanks" runat="server">Details Saved, Thank You</asp:Label>
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" Width="156px" /><br />
        <br />
        <span >
        *Enter Your Discount Code Number to receive 20% off your first Booking.
        <br />
        Discount does not apply to cost of materials.<br />
        </span>
    </div>        
   
</asp:Content>

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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

22 Experts available now in Live!

Get 1:1 Help Now