Solved

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

Posted on 2006-11-16
4
327 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
[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
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

752 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