Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 4th, 2010, 09:29 AM
Authorized User
 
Join Date: Aug 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with jquery ch 11

error message: '$.updnWatermark' is null or not an object. This error occur when I request the page in the browser. What am I doing wrong or missing?

Code:
<script src="../Scripts/jquery.updnWatermark.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $.updnWatermark.attachAll({ cssClass: 'Watermark' });        $('form').bind('submit', function () {
            if (Page_IsValid) {
                $('#TableWrapper').slideUp(3000);
            }
        });
    });

    function pageLoad() {
        $('.Attention').animate({ width: '600px' }, 3000).animate({ width: '100px' }, 3000).fadeOut('slow');
    }
</script>
Reply With Quote
  #2 (permalink)  
Old October 4th, 2010, 09:40 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Did you include a reference to the jQuery library?

And is the jquery.updnWatermark.js library located in the Script folder in the parent folder of the page / control you're testing this on? If this code comes directly from the user control in the Contact.aspx page in the About folder in the root (as is the case if you follow along with the book), the Scripts folder should be in the root.

Hope tis helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old October 4th, 2010, 12:25 PM
Authorized User
 
Join Date: Aug 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default jquery

I have it working on the Contact.aspx page.

I have another question. I have change the format slightly. I placed the following code
Code:
<uc1:ContactForm ID="ContactForm1" runat="server" />
in the default.aspx page.

The watermark doesn't not work in the default.aspx page. Do you have a code that the watermark will run right when the default.aspx page, with the contact form is loaded. I found a code called document ready.

Sample Code

Code:
<script type="text/javascript">
        $(document).ready(function() {
        $("#Button1").click(function() {
            alert("Hello world!");
        });
 
        });
    </script>
Can you tell me if this will work? If so, where will I put it and how?
Reply With Quote
  #4 (permalink)  
Old October 4th, 2010, 01:11 PM
Authorized User
 
Join Date: Aug 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default jquery

I'm sorry. I had two web sites open. I do have the form working in the contact.aspx page.

I slightly change the format of the web site and placed the following code in the default.aspx page.
Code:
<uc1:ContactForm ID="ContactForm1" runat="server" />
The watermark doesn't work on the default.aspx page. Can the watermark work when I run the default.aspx right when the page is loaded?

I founded a code called document ready

Sample Code

[code]


<script type="text/javascript">
$(document).ready(function() {
$("#Button1").click(function() {
alert("Hello world!");
});

});
</script>

Can I use this code? If so, what do I need to do? how do I do it and where will I place the code to make it work on the Default.aspx.page when I view it in the browser.


Code for the default.aspx page
Code:
<%@ Page Title="Welcome to Maintenance Request Form" Language="C#" MasterPageFile="~/MasterPages/FrontEnd.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="MasterPages_Default" %>

<%@ Register src="Controls/ContactForm.ascx" tagname="ContactForm" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
   

    <style type="text/css">
        .style1
        {
            color: #FF0000;
        }
        .style2
        {
            color: #000000;
            text-align: center;
            font-size: x-large;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    
    <h1 class="style2">
   Welcome to the Maintenance Request Form</h1>
<p>For an <span class="style1">EMERGENCY</span> or <span class="style1">URGENT</span> 
    matter Call Facility Management at: RTP: 
     HYATTSVILLE: 
     &quot;or&quot; 
</p>
 
    <uc1:ContactForm ID="ContactForm1" runat="server" />
</asp:Content>
code for the contact form

Code:
<script src="../Scripts/jquery.updnWatermark.js" type="text/javascript"></script>
<script type="text/javascript">
  
  
    $(function () {
                    
        $.updnWatermark.attachAll({ cssClass: 'Watermark' });
        $('form').bind('submit', function () {
            if (Page_IsValid) {
                $('#TableWrapper').slideUp(3000);
            }
        });
    });
    });
    function pageLoad() {
        $('.Attention').animate({ width: '600px' }, 3000).animate({ width: '100px' }, 3000).fadeOut('slow');
    }
});
</script>
Reply With Quote
  #5 (permalink)  
Old October 4th, 2010, 05:05 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

I don't understand what you're asking or what the problem is. Can you elaborate?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
Antonius Block (January 26th, 2014)
  #6 (permalink)  
Old October 6th, 2010, 08:57 AM
Authorized User
 
Join Date: Aug 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default jQuery Ch 11

I have alter the web site slightly . I placed the controls/contactform.ascx user control on the about/contact.aspx page and the default.aspx page.

The watermark text works on the about/contact.aspx page but when I placed the controls/contactform on the Default.aspx page I get the following error when I open the Planet wrox site in the brower.

Microsoft JScript runtime error: '$.updnWatermark' is null or not an object


Questions.

1. Can the contactform.asxc user contol (with the watermark text) be used in the default.aspx page?

2. Can I use the jquery code
Code:
 $(document). ready(function() {
to load the default.aspx page (with the usercontrol and watermark text).

3. If so ,Can you help me write the correct code or format the correct code, so I will not get this error?

I hope I explained this better? Sorry,about the long code, but this is what I see when I get the error. Thank you


jscript debugger code

Code:
<!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><title>
	Welcome to Maintenance Request Form
</title>
   

    <style type="text/css">
        .style1
        {
            color: #FF0000;
        }
        .style2
        {
            color: #000000;
            text-align: center;
            font-size: x-large;
        }
    </style>
<link href="App_Themes/RTP/RTP.css" type="text/css" rel="stylesheet" /><style type="text/css">
	.TreeView1_0 { text-decoration:none; }
	.TreeView1_1 { border-style:none; }
	.TreeView1_2 {  }

</style></head>
<body>
    <form method="post" action="Default.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="TreeView1_ExpandState" id="TreeView1_ExpandState" value="nennennn" />
<input type="hidden" name="TreeView1_SelectedNode" id="TreeView1_SelectedNode" value="TreeView1n0" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="TreeView1_PopulateLog" id="TreeView1_PopulateLog" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTIwMDgzODYxMzcPZBYCZg9kFgICAw9kFgYCBQ88KwANAQAPFgIeB1Zpc2libGVoZGQCBw8UKwAJDxYIHg1OZXZlckV4cGFuZGVkZB4LXyFEYXRhQm91bmRnHgxTZWxlY3RlZE5vZGUFC1RyZWVWaWV3MW4wHglMYXN0SW5kZXgCCGRkZGRkZGQQFgAWAGQUKwAFBQ8wOjAsMDoxLDA6MiwwOjMUKwACFhAeBFRleHQFBEhvbWUeBVZhbHVlBQRIb21lHgtOYXZpZ2F0ZVVybAUSL1NpdGUvRGVmYXVsdC5hc3B4HgdUb29sVGlwBRJHbyB0byB0aGUgaG9tZXBhZ2UeCERhdGFQYXRoBRIvc2l0ZS9kZWZhdWx0LmFzcHgeCURhdGFCb3VuZGceCFNlbGVjdGVkZx4IRXhwYW5kZWRnZBQrAAIWEh8GBQdSZXZpZXdzHwpnHwUFB1Jldmlld3MfBwUaL1NpdGUvUmV2aWV3cy9EZWZhdWx0LmFzcHgeCVBvcHVsYXRlZGcfDGcfCAUeUmV2aWV3cyBwdWJsaXNoZWQgb24gdGhpcyBzaXRlHwkFGi9zaXRlL3Jldmlld3MvZGVmYXVsdC5hc3B4HhBQb3B1bGF0ZU9uRGVtYW5kaBQrAAMFBzA6MCwwOjEUKwACFg4fBQUIQnkgR2VucmUfBgUIQnkgR2VucmUfBwUdL1NpdGUvUmV2aWV3cy9BbGxCeUdlbnJlLmFzcHgfCAUcQWxsIFJldmlld3MgR3JvdXBlZCBieSBHZW5yZR8JBR0vc2l0ZS9yZXZpZXdzL2FsbGJ5Z2VucmUuYXNweB8KZx8MZ2QUKwACFg4fBQULQWxsIFJldmlld3MfBgULQWxsIFJldmlld3MfBwUWL1NpdGUvUmV2aWV3cy9BbGwuYXNweB8IBQtBbGwgUmV2aWV3cx8JBRYvc2l0ZS9yZXZpZXdzL2FsbC5hc3B4HwpnHwxnZBQrAAIWEh8GBQVBYm91dB8KZx8FBQVBYm91dB8HBRgvU2l0ZS9BYm91dC9EZWZhdWx0LmFzcHgfDWcfDGcfCAUPQWJvdXQgdGhpcyBTaXRlHwkFGC9zaXRlL2Fib3V0L2RlZmF1bHQuYXNweB8OaBQrAAMFBzA6MCwwOjEUKwACFg4fBQUKQ29udGFjdCBVcx8GBQpDb250YWN0IFVzHwcFGC9TaXRlL0Fib3V0L0NvbnRhY3QuYXNweB8IBQpDb250YWN0IFVzHwkFGC9zaXRlL2Fib3V0L2NvbnRhY3QuYXNweB8KZx8MZ2QUKwACFg4fBQUIQWJvdXQgVXMfBgUIQWJvdXQgVXMfBwUYL1NpdGUvQWJvdXQvQWJvdXRVcy5hc3B4HwgFCEFib3V0IFVzHwkFGC9zaXRlL2Fib3V0L2Fib3V0dXMuYXNweB8KZx8MZ2QUKwACFg4fBQUFTG9naW4fBgUFTG9naW4fBwUQL1NpdGUvTG9naW4uYXNweB8IBRdMb2cgaW4gdG8gdGhpcyB3ZWIgc2l0ZR8JBRAvc2l0ZS9sb2dpbi5hc3B4HwpnHwxnZGQCCw8QZGQWAQIBZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAgUPY3RsMDAkVHJlZVZpZXcxBSdjdGwwMCRjcE1haW5Db250ZW50JENvbnRhY3RGb3JtMSROb3RpZnmY3ULDZOmChZDjGh8+KFZeFyT5LGvybAP6WfpRr4mfsw==" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<script src="/Site/WebResource.axd?d=3a3KrUu4LUn4bBtKVYwVJN-Cv0ys_a1-w4GrGSdbwdgzusvsage729IIgdUiSKNceynOWMl4C4p5gbf_YX7tlLw85jJxloD0Takkftl7XPI1&amp;t=634218343197341394" type="text/javascript"></script>


<script src="/Site/ScriptResource.axd?d=vWAnnx4SZnsK2nURxVqUyHj7aDnVTvTnNPk0aIuC-2h-ZiDd8B49uCZixfkOeMmj4G9n100S_0CXFqAufJ7mgOOkDG5flh8knYkwmcwRFOmYy1F0ntEr3VWlFr4mhHcRWUgpeZkihs3Eeyif2O0Wrg2&amp;t=6df0ad7a" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[

    function TreeView_PopulateNodeDoCallBack(context,param) {
        WebForm_DoCallback(context.data.treeViewID,param,TreeView_ProcessNodeData,context,TreeView_ProcessNodeData,false);
    }
var TreeView1_Data = null;//]]>
</script>

<script src="/Site/ScriptResource.axd?d=FdV29aH6hNcqDl56L1s3FTTnp56UpHReJ5S5MJV2IvJG6BEUwq4aiA6Eg-4qzps3pd0mrdTwcecPmYidcCLCO5YBZjnKpD9Sf_ktMQ-5R_fLCNEOjMv7r5ZHXjHr-xAhSEpzqnFhVoKybiRY8xQUShSu-ckdOHTmRUFt9KimcO41&amp;t=6df0ad7a" type="text/javascript"></script>
<script src="/Site/ScriptResource.axd?d=9Dgdb8v95WR8zffa1TXKZGf2V5A_8y_8xP5sx6yXiFku6upiG7AVCrJrgcnxIYjmBeEak1rzAND0PoQR5jJImVqf07y4fRyX4lujYP7UWnhOhddKW3lEYjdOH4i_Q9kGt6N1NtOqs98f1NFULdfcnfpigdr-Cqe0BUJciO9kA3SSAcGWQE6nYpMDY9eeTO7-0&amp;t=2610f696" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>

<script src="/Site/ScriptResource.axd?d=AXyyeiuyE2SLkZnnE6z9_kelO3LUd3dQiZ9PhcVTBqyk7ed7McXX-uInNiPjhcZc-QicyiiyqBtEYL1hCunJ6d_idMcflVoDaiQHQ8c5lEgftfzojL4I6nKe_SUl6tb7Gn3F9EPXyLUu04MPFXl2W6TsonLD82lYYfWM2_vbatjDFnxRQGxOWA_hDxNLQjey0&amp;t=2610f696" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>

<div class="aspNetHidden">

	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWDQLM85OfCQKUw8moBALQlLO+CgL8+YfuDwKf+djgDwKJlt2PDgKN0prZDwK1/7a4AwKhp6mCBQKRqP6/CQKlpMaQDAKHs/+sAgLJ1PzKCX2Qb27C2Q7yqgI1iWauqL+l5WGsJmYY7BkuduxMY8MQ" />
</div>
    <script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ctl00$ScriptManager1', 'form1', ['tctl00$cpMainContent$ContactForm1$UpdatePanel1','cpMainContent_ContactForm1_UpdatePanel1'], [], [], 90, 'ctl00');
//]]>
</script>

        
    <div id ="Pagewrapper">
    <div id="Header"> <a href="./"></a></div>
    <div id="MenuWrapper">
          
        <a href="#TreeView1_SkipLink"><img alt="Skip Navigation Links." src="/Site/WebResource.axd?d=NkC2Q3xYDo6xVLBgMi2eQ8lv62nOPtw83KJyTHEdZ_Q9OWsCP03g8rdIir1xKNK5UUbMR48h6XErIP-2vHY3VyzXvILskR9vx_HqfQMRihs1&amp;t=634218343197341394" width="0" height="0" style="border-width:0px;" /></a><div id="TreeView1">
	<table cellpadding="0" cellspacing="0" style="border-width:0;">
		<tr>
			<td class="FirstLevelMenuItems TreeView1_2" style="white-space:nowrap;"><a class="TreeView1_0 FirstLevelMenuItems TreeView1_1" href="/Site/Default.aspx" title="Go to the homepage" id="TreeView1n0" style="border-style:none;font-size:1em;">Home</a></td>
		</tr>
	</table><table cellpadding="0" cellspacing="0" style="border-width:0;">
	[:o)]	<tr>
			<td class="FirstLevelMenuItems TreeView1_2" style="white-space:nowrap;"><a class="TreeView1_0 FirstLevelMenuItems TreeView1_1" href="/Site/Reviews/Default.aspx" title="Reviews published on this site" id="TreeView1n1" style="border-style:none;font-size:1em;">Reviews</a></td>
		</tr>
	</table><div id="TreeView1n1Nodes" style="display:block;">
		<table cellpadding="0" cellspacing="0" style="border-width:0;">
			<tr>
				<td><div style="width:20px;height:1px"></div></td><td style="white-space:nowrap;"><a class="TreeView1_0" href="/Site/Reviews/AllByGenre.aspx" title="All Reviews Grouped by Genre" id="TreeView1n2">By Genre</a></td>
			</tr>
		</table><table cellpadding="0" cellspacing="0" style="border-width:0;">
			<tr>
				<td><div style="width:20px;height:1px"></div></td><td style="white-space:nowrap;"><a class="TreeView1_0" href="/Site/Reviews/All.aspx" title="All Reviews" id="TreeView1n3">All Reviews</a></td>
			</tr>
		</table>
	</div><table cellpadding="0" cellspacing="0" style="border-width:0;">
		<tr>
			<td class="FirstLevelMenuItems TreeView1_2" style="white-space:nowrap;"><a class="TreeView1_0 FirstLevelMenuItems TreeView1_1" href="/Site/About/Default.aspx" title="About this Site" id="TreeView1n4" style="border-style:none;font-size:1em;">About</a></td>
		</tr>
	</table><div id="TreeView1n4Nodes" style="display:block;">
		<table cellpadding="0" cellspacing="0" style="border-width:0;">
			<tr>
				<td><div style="width:20px;height:1px"></div></td><td style="white-space:nowrap;"><a class="TreeView1_0" href="/Site/About/Contact.aspx" title="Contact Us" id="TreeView1n5">Contact Us</a></td>
			</tr>
		</table><table cellpadding="0" cellspacing="0" style="border-width:0;">
			<tr>
				<td><div style="width:20px;height:1px"></div></td><td style="white-space:nowrap;"><a class="TreeView1_0" href="/Site/About/AboutUs.aspx" title="About Us" id="TreeView1n6">About Us</a></td>
			</tr>
		</table>
	</div><table cellpadding="0" cellspacing="0" style="border-width:0;">
		<tr>
			<td class="FirstLevelMenuItems TreeView1_2" style="white-space:nowrap;"><a class="TreeView1_0 FirstLevelMenuItems TreeView1_1" href="/Site/Login.aspx" title="Log in to this web site" id="TreeView1n7" style="border-style:none;font-size:1em;">Login</a></td>
		</tr>
	</table>
</div><a id="TreeView1_SkipLink"></a>
        <br />
            
            </div>
<div id ="Sidebar">Selection Location:<br />
<select name="ctl00$ThemeList" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ThemeList\',\'\')', 0)" id="ThemeList">
	<option value="Hyattsville">Hyattsville</option>
	<option selected="selected" value="RTP">RTP</option>

</select>
    </div>
    <div id="MainContent"> 
    <br />
        <br />
        <span id="SiteMapPath1"><a href="#SiteMapPath1_SkipLink"><img alt="Skip Navigation Links" height="0" width="0" src="/Site/WebResource.axd?d=NkC2Q3xYDo6xVLBgMi2eQ8lv62nOPtw83KJyTHEdZ_Q9OWsCP03g8rdIir1xKNK5UUbMR48h6XErIP-2vHY3VyzXvILskR9vx_HqfQMRihs1&amp;t=634218343197341394" style="border-width:0px;" /></a><span><a title="Home" href="/Site/">Home</a></span><span> &gt; </span><span>Home</span><a id="SiteMapPath1_SkipLink"></a></span>
        <br />
        <br />
         
    
    <h1 class="style2">
   Welcome to the Maintenance Request Form</h1>
<p>For an <span class="style1">EMERGENCY</span> or <span class="style1">URGENT</span> 
    matter Call Facility Management at: RTP: 
     HYATTSVILLE: 
    &quot;or&quot; 
</p>
 
    

<style type="text/css">
    .style1
    {
        width: 100%;
    }
    .style3
    {
        height: 40px;
    }
    .style4
    {
        height: 25px;
    }
    .style5
    {
        width: 459px;
    }
    .style6
    {
        height: 25px;
        width: 459px;
    }
    .style7
    {
        height: 40px;
        width: 459px;
    }
</style>
<script type="text/javascript">
    function ValidatePhoneNum(source, args) {
        var PhoneNum= document.getElementById('cpMainContent_ContactForm1_PhoneNum');
        var UserID = document.getElementById('cpMainContent_ContactForm1_UserID');
        if (PhoneNum.value != '' || UserID.value != '') {
            args.IsValid = true;
        }
        else {
            args.IsValid = false;
        }
    }
</script>

<div id="cpMainContent_ContactForm1_UpdatePanel1">
	
<div id="TableWrapper">
<table id="cpMainContent_ContactForm1_FormTable" class="style1">
		<tr>
			<td colspan="3">
            Please use this form when requesting routine building maintenance.</td>
		</tr>
		<tr>
			<td>
            User ID:</td>
			<td class="style5">
            <input name="ctl00$cpMainContent$ContactForm1$UserID" type="text" id="cpMainContent_ContactForm1_UserID" title="Enter your UserID" class="InputBox" />
        </td>
			<td>
            &nbsp;</td>
		</tr>
		<tr>
			<td>
            First
            Name:</td>
			<td class="style5">
            <input name="ctl00$cpMainContent$ContactForm1$FirstName" type="text" id="cpMainContent_ContactForm1_FirstName" title="Enter your First Name" class="InputBox" />
        </td>
			<td>
            <span id="cpMainContent_ContactForm1_RequiredFieldValidator1" class="ErrorMessage" style="visibility:hidden;">*</span>
        </td>
		</tr>
		<tr>
			<td class="style4">
            Last Name:</td>
			<td class="style6">
            <input name="ctl00$cpMainContent$ContactForm1$LastName" type="text" id="cpMainContent_ContactForm1_LastName" title="Enter your Last Name" class="InputBox" />
        </td>
			<td class="style4">
            <span id="cpMainContent_ContactForm1_RequiredFieldValidator3" class="ErrorMessage" style="visibility:hidden;">*</span>
        </td>
		</tr>
		<tr>
			<td>
            Room Number:</td>
			<td class="style5">
            <input name="ctl00$cpMainContent$ContactForm1$RoomNum" type="text" id="cpMainContent_ContactForm1_RoomNum" title="Enter your Room Number" class="InputBox" />
        </td>
			<td>
            &nbsp;</td>
		</tr>
		<tr>
			<td>
            Phone Number:</td>
			<td class="style5">
            <input name="ctl00$cpMainContent$ContactForm1$PhoneNum" type="text" id="cpMainContent_ContactForm1_PhoneNum" title="Enter your Phone Number" class="InputBox" />
        </td>
			<td>
            <span id="cpMainContent_ContactForm1_CustomValidator1" class="ErrorMessage" style="display:none;">*</span>
        </td>
		</tr>
		<tr>
			<td>
            Location of Desired Service or Room Number:</td>
			<td class="style5">
            <input name="ctl00$cpMainContent$ContactForm1$Location" type="text" id="cpMainContent_ContactForm1_Location" title="Enter the Location" class="InputBox" />
        </td>
			<td>
            &nbsp;</td>
		</tr>
		<tr>
			<td class="style3">
            If you desire notification upon completion of the<br />
            request, check the box.</td>
			<td class="style7">
            <input id="cpMainContent_ContactForm1_Notify" type="checkbox" name="ctl00$cpMainContent$ContactForm1$Notify" />
        </td>
			<td class="style3">
            </td>
		</tr>
		<tr>
			<td class="style3">
            Comments:</td>
			<td class="style7">
            <textarea name="ctl00$cpMainContent$ContactForm1$Comments" rows="2" cols="20" id="cpMainContent_ContactForm1_Comments" title="Comments" class="InputBox" style="height:141px;">
</textarea>
        </td>
			<td class="style3">
            <span id="cpMainContent_ContactForm1_RequiredFieldValidator2" class="ErrorMessage" style="visibility:hidden;">*</span>
        </td>
		</tr>
		<tr>
			<td>
            &nbsp;</td>
			<td class="style5">
            <input type="submit" name="ctl00$cpMainContent$ContactForm1$SendButton" value="Submit" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$cpMainContent$ContactForm1$SendButton&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="cpMainContent_ContactForm1_SendButton" />
        </td>
			<td>
            &nbsp;</td>
		</tr>
		<tr>
			<td colspan="3">
            <div id="cpMainContent_ContactForm1_ValidationSummary1" class="ErrorMessage" style="display:none;">

			</div>
        </td>
		</tr>
	</table>
	
</div>



</div>
<div id="cpMainContent_ContactForm1_UpdateProgress1" style="display:none;">
	
    <div class="PleaseWait">Please Wait... </div>
  
</div>
<script src="../Scripts/jquery.updnWatermark.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $.updnWatermark.attachAll({ cssClass: 'Watermark' });
        $('form').bind('submit', function () {
            if (Page_IsValid) {
                $('#TableWrapper').slideUp(3000);
            }
        });
    });

    function pageLoad() {
        $('.Attention').animate({ width: '600px' }, 3000).animate({ width: '100px' }, 3000).fadeOut('slow');
    }
</script>


      </div>
    
    <div id ="Footer">Footer Goes Here</div>
      </div>
   
  
    
<script type="text/javascript">
//<![CDATA[
var TreeView1_ImageArray =  new Array('', '', '', '/Site/WebResource.axd?d=illk7Ez5Jy3kMVoUd-suiItW4dxLXyywgjWn-1g-agLeEjwW25joaDur3IE2utyDNaHLWrh77qsp1-NzWjMTiQS3B-KH-L4V7w25-13x5aLC2tb578lP8yEZlcJq4j1B0&t=634218343197341394', '/Site/WebResource.axd?d=bFpb_xuRuFM4rLdKenfOFYy5IIVvGYynNS7nssX5N4GAoOPnjpkteq7kjajhHMfzeeZbOkdCDe9d--u-0OWi0kSNSrRvUrTXq-O_oiPSAtLa6Bzr7rU4ZvNPZLzgfiH70&t=634218343197341394', '/Site/WebResource.axd?d=nZYJ3t4B_-IvUnUOgiOUMgoGqL2C-UPCi0ppeIWU9aidXiajN7SjbaAFY1tqNBrm02wk32zhS_8FQhLtgqNyW6xZH2VOSYV6jTedOfqCVQv7q0cSJYehRopeDVXTlQqM0&t=634218343197341394');
var Page_ValidationSummaries =  new Array(document.getElementById("cpMainContent_ContactForm1_ValidationSummary1"));
var Page_Validators =  new Array(document.getElementById("cpMainContent_ContactForm1_RequiredFieldValidator1"), document.getElementById("cpMainContent_ContactForm1_RequiredFieldValidator3"), document.getElementById("cpMainContent_ContactForm1_CustomValidator1"), document.getElementById("cpMainContent_ContactForm1_RequiredFieldValidator2"));
//]]>
</script>

<script type="text/javascript">
//<![CDATA[
var cpMainContent_ContactForm1_RequiredFieldValidator1 = document.all ? document.all["cpMainContent_ContactForm1_RequiredFieldValidator1"] : document.getElementById("cpMainContent_ContactForm1_RequiredFieldValidator1");
cpMainContent_ContactForm1_RequiredFieldValidator1.controltovalidate = "cpMainContent_ContactForm1_FirstName";
cpMainContent_ContactForm1_RequiredFieldValidator1.errormessage = "Enter Your Name";
cpMainContent_ContactForm1_RequiredFieldValidator1.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
cpMainContent_ContactForm1_RequiredFieldValidator1.initialvalue = "";
var cpMainContent_ContactForm1_RequiredFieldValidator3 = document.all ? document.all["cpMainContent_ContactForm1_RequiredFieldValidator3"] : document.getElementById("cpMainContent_ContactForm1_RequiredFieldValidator3");
cpMainContent_ContactForm1_RequiredFieldValidator3.controltovalidate = "cpMainContent_ContactForm1_LastName";
cpMainContent_ContactForm1_RequiredFieldValidator3.errormessage = "Enter Last Name";
cpMainContent_ContactForm1_RequiredFieldValidator3.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
cpMainContent_ContactForm1_RequiredFieldValidator3.initialvalue = "";
var cpMainContent_ContactForm1_CustomValidator1 = document.all ? document.all["cpMainContent_ContactForm1_CustomValidator1"] : document.getElementById("cpMainContent_ContactForm1_CustomValidator1");
cpMainContent_ContactForm1_CustomValidator1.errormessage = "Enter your Phone Number or UserID";
cpMainContent_ContactForm1_CustomValidator1.display = "Dynamic";
cpMainContent_ContactForm1_CustomValidator1.evaluationfunction = "CustomValidatorEvaluateIsValid";
cpMainContent_ContactForm1_CustomValidator1.clientvalidationfunction = "ValidatePhoneNum";
var cpMainContent_ContactForm1_RequiredFieldValidator2 = document.all ? document.all["cpMainContent_ContactForm1_RequiredFieldValidator2"] : document.getElementById("cpMainContent_ContactForm1_RequiredFieldValidator2");
cpMainContent_ContactForm1_RequiredFieldValidator2.controltovalidate = "cpMainContent_ContactForm1_Comments";
cpMainContent_ContactForm1_RequiredFieldValidator2.errormessage = "Enter a Comment";
cpMainContent_ContactForm1_RequiredFieldValidator2.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
cpMainContent_ContactForm1_RequiredFieldValidator2.initialvalue = "";
var cpMainContent_ContactForm1_ValidationSummary1 = document.all ? document.all["cpMainContent_ContactForm1_ValidationSummary1"] : document.getElementById("cpMainContent_ContactForm1_ValidationSummary1");
cpMainContent_ContactForm1_ValidationSummary1.headertext = "\"Please correct the following errors before you press the Submit button\"";
//]]>
</script>


<script type="text/javascript">
//<![CDATA[

WebForm_InitCallback();var TreeView1_Data = new Object();
TreeView1_Data.images = TreeView1_ImageArray;
TreeView1_Data.collapseToolTip = "Collapse {0}";
TreeView1_Data.expandToolTip = "Expand {0}";
TreeView1_Data.expandState = theForm.elements['TreeView1_ExpandState'];
TreeView1_Data.selectedNodeID = theForm.elements['TreeView1_SelectedNode'];
(function() {
  for (var i=0;i<6;i++) {
  var preLoad = new Image();
  if (TreeView1_ImageArray[i].length > 0)
    preLoad.src = TreeView1_ImageArray[i];
  }
})();
TreeView1_Data.lastIndex = 8;
TreeView1_Data.populateLog = theForm.elements['TreeView1_PopulateLog'];
TreeView1_Data.treeViewID = 'ctl00$TreeView1';
TreeView1_Data.name = 'TreeView1_Data';

var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
    ValidatorOnLoad();
}

function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    else {
        return true;
    }
}
        
document.getElementById('cpMainContent_ContactForm1_ValidationSummary1').dispose = function() {
    Array.remove(Page_ValidationSummaries, document.getElementById('cpMainContent_ContactForm1_ValidationSummary1'));
}

document.getElementById('cpMainContent_ContactForm1_RequiredFieldValidator1').dispose = function() {
    Array.remove(Page_Validators, document.getElementById('cpMainContent_ContactForm1_RequiredFieldValidator1'));
}

document.getElementById('cpMainContent_ContactForm1_RequiredFieldValidator3').dispose = function() {
    Array.remove(Page_Validators, document.getElementById('cpMainContent_ContactForm1_RequiredFieldValidator3'));
}

document.getElementById('cpMainContent_ContactForm1_CustomValidator1').dispose = function() {
    Array.remove(Page_Validators, document.getElementById('cpMainContent_ContactForm1_CustomValidator1'));
}

document.getElementById('cpMainContent_ContactForm1_RequiredFieldValidator2').dispose = function() {
    Array.remove(Page_Validators, document.getElementById('cpMainContent_ContactForm1_RequiredFieldValidator2'));
}
Sys.Application.add_init(function() {
    $create(Sys.UI._UpdateProgress, {"associatedUpdatePanelId":"cpMainContent_ContactForm1_UpdatePanel1","displayAfter":500,"dynamicLayout":true}, null, null, $get("cpMainContent_ContactForm1_UpdateProgress1"));
});
//]]>
</script>
</form>
</body>
</html>
Reply With Quote
  #7 (permalink)  
Old October 6th, 2010, 09:52 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

If it works in one page and not another, then my guess is that it's related to the path to the jQuery file or the plugin library:

Code:
 
<script src="../Scripts/jquery.updnWatermark.js" type="text/javascript"></script>
...
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
Notice how you're using two different ways to address the same Scripts folder.
Are you running this from a subfolder? Then Watermark gets loaded as the script link above goes one folder up from the current page, and then one folder down into the Scripts folder. Is that indeed the case?
Are you running this from the root? Then the jQuery library gets loaded but not the other.

Check out Chapter 7 for more information about root based and relative paths.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #8 (permalink)  
Old October 31st, 2011, 10:37 AM
Authorized User
Points: 233, Level: 4
Points: 233, Level: 4 Points: 233, Level: 4 Points: 233, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 44
Thanks: 14
Thanked 0 Times in 0 Posts
Default

Hi Imar,

your response here gave me the hint to solve my problem with the jQuery plugin updnWatermark. Previously, I pointed to the plugin from the ContactForm.ascx with the root-based path ~/ and it didn't work.

The problem, now, is that I cannot understand why it didn't work.

In your sources for chapter 11, you successfully point to the jQuery library from the master page (which is in a folder) with the root-based path ~/.

Why cannot I point from the ContactForm.ascx (which is in a folder) to the plugin with the root-based path too ?

Thanks




Quote:
Originally Posted by Imar View Post
If it works in one page and not another, then my guess is that it's related to the path to the jQuery file or the plugin library:

Code:
 
<script src="../Scripts/jquery.updnWatermark.js" type="text/javascript"></script>
...
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
Notice how you're using two different ways to address the same Scripts folder.
Are you running this from a subfolder? Then Watermark gets loaded as the script link above goes one folder up from the current page, and then one folder down into the Scripts folder. Is that indeed the case?
Are you running this from the root? Then the jQuery library gets loaded but not the other.

Check out Chapter 7 for more information about root based and relative paths.

Cheers,

Imar
Reply With Quote
  #9 (permalink)  
Old October 31st, 2011, 11:08 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

In the MasterPage a ScriptManager is used to register the script. The ScriptManager is able to resolve root based paths starting with a ~, making sure the path is correct no matter where the page is located that uses this master page.

If you directly put the JavaScript in a User Control the literal path (e.. Scripts/ or /Scripts/ or ../Scripts/) or whatever is used which may or may not work depending on the location of the page that uses the User Control.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #10 (permalink)  
Old February 23rd, 2012, 06:26 PM
Authorized User
Points: 353, Level: 6
Points: 353, Level: 6 Points: 353, Level: 6 Points: 353, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 86
Thanks: 20
Thanked 3 Times in 3 Posts
Default Error: property of 'attachAll': object null-undefined

Hi Imar,

I get this error trying to use updnWatermark: Error: Unable to get value of the property 'attachAll': object is null or undefined

I can run your sample page from the root of site and it works fine. However, as a user control I keep getting this error. I set up a little test together with 2 pages: Contact.aspx is in the root and ContactForm.ascx is in the Controls folder.

Contact.aspx
----------------------------------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="contact.aspx.vb" Inherits="contact" %>

<%@ Register Src="~/Controls/ContactForm.ascx" TagName="ContactForm" TagPrefix="uc1" %>

<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
We are in the Main Page
<uc1:ContactForm ID="ContactForm1" runat="server" />
</div>
</form>
</body>
</html>
------------------------------------------------------

ContactForm.ascx
-----------------------------------------
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ContactForm.ascx.vb" Inherits="Controls_ContactForm" %>
<style type="text/css">
.Watermark
{
position: relative;
width: 0;
height: 1.25em;
vertical-align: top;
}
.Watermark label
{
position: absolute;
left: 0;
top: 2px;
white-space: nowrap;
color: #999;
padding-left: 4px;
height: 1.25em;
vertical-align: middle;
}
.InputBox
{
width: 300px;
}
</style>

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
<Scripts>
<asp:ScriptReference Path="~/Scripts/jquery-1.4.1.min.js" />
</Scripts>
</asp:ScriptManager>

<p> We are in the user control</p>

<div>
<asp:TextBox ID="CriteriaTextBox" runat="server" ToolTip="Please enter the User Name" CssClass="InputBox"></asp:TextBox>
</div>

<script src="/Scripts/jquery.updnWatermark.js" type="text/javascript"></script>
<script type="text/javascript">

$(function ()
{
alert("just before the updnWatermark call");

$.updnWatermark.attachAll({ cssClass: 'Watermark' });

alert("We never get here");
});
</script>
------------------------------------------------------------

In the browser
------------------------------
We are in the Main Page
We are in the user control

[a blank text box ]

Then the " just before the updnWatermark call" alert message

And then the error message: : Unable to get value of the property 'attachAll': object is null or undefined

---------------------------------------

I've been fiddling with all sorts of path issues to no avail.

Last edited by daveharney; February 23rd, 2012 at 06:29 PM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JQuery Troubles- Chapter 11, Exercise 1 Princess Rose BOOK: Beginning ASP.NET 4 : in C# and VB 6 May 3rd, 2010 05:35 PM
Ch 11 Question tixrus BOOK: Beginning JavaScript and CSS Development with jQuery 0 April 11th, 2010 05:23 PM
Problem Playing Video using listings 11-4 through 11-6 emanuel BOOK: Professional Android 2 Application Development 3 April 7th, 2010 02:16 PM
Ch 11 Pg459 Exercise 5 C# brivad BOOK: Beginning ASP.NET 1.0 0 September 10th, 2007 08:59 AM



All times are GMT -4. The time now is 02:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.