 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 25th, 2010, 11:24 AM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Error in User Control
i drag the user control from the controls folder to the contact form, and it gives me, a red error on the design, error rendering control.
the registration of the control in page is:
Code:
<%@ Register src="../Controls/ContactForm.ascx" tagname="ContactForm" tagprefix="uc1" %>
and the control in markup is :
Code:
<uc1:ContactForm ID="ContactForm1" runat="server" />
I may have warning in the JQuery causing that, it tells me expecting more source characters, and a green line under the beginning of the word </script>
any advice?
|

September 25th, 2010, 11:53 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I feel like a broken record but can you please post the relevant code? For the page and the user control in this case.
I feel like a broken record but can you please post the relevant code? For the page and the user control in this case.
I feel like a broken record but can you please post the relevant code? For the page and the user control in this case.
I feel like a broken record but can you please post the relevant code? For the page and the user control in this case.
I don't understand how you think we can help you if you don't provide the information we need to figure out what's going on....
BTW: Did the answers to your jQuery questions help?
Imar
|

September 25th, 2010, 12:39 PM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes the first answer i found in page 392 which i haven't reach yet that time, and the answer about the the innerHTML still vague to me but it's alright i'm gonna take it from there and google it. and I took ur advice and am gona post on the JavaScript forms but i think i have to read more about JQuery to have a great background about it first. thanks for answering my Questions although some of them (if not all) seem to be silly, but i'm still a beginner in the development field in general.
back to my Question..
here is the code for the javascript at the end of the ASCX file:
Code:
<script type="text/javascript">
$(function()
{
$(':input[type=text], textarea').each
(
function()
{
var newText = 'Enter your ' +
$(this).parent().prev().text().toLowerCase().trim();
$(this).attr('value', newText);
}).one('focus', function()
{
this.value = '', this.className = ''
}).addClass('watermark').css('width', '300px');
$('form').bind('submit',function(){
if(Page_IsValid){
$('#TableWrapper').slideUp(3000);
}
});
function pageload(){
$('.Attention').animate({width:'600px'},3000).animate({width:'100px'},3000).fadeOut('slow');}
</script>
i have deleted the whole javascript snippet from the page, but still getting the same result
|

September 25th, 2010, 12:52 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
The error is on line 11 of the code you're not posting....
Cheers,
Imar
|

September 25th, 2010, 12:57 PM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
what line 11?
and what error im not posting?
|

September 25th, 2010, 01:06 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
what line 11?
and what error im not posting?
|
I don't know. I have asked you many times to provide the relevant souce for the page and the user control. You're not doing that, so I am posting random suggestions in the hopes that one will be spot on. That seems to be the best way to deal with your questions.
Sorry if I sound cynical, but on pretty much every post you made I had to ask for follow up code, which you're not providing. I don't know what you think, but I don't understand how you think we can make useful suggestions without seeing the full source. Clearly, something is wrong with rendering the control. What the problem is, nobody knows. It could be the user control, it could be the page, it could be your machine, it could be your settings. You're not giving me enough to reproduce the problem (e.g. recreate your page and drop a control) so I can't recommend a fix....
Imar
Last edited by Imar; September 25th, 2010 at 01:23 PM..
|

September 25th, 2010, 01:28 PM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok ok ok ok, easy man.. sorry about that, it's just the code is too long I thought it wouldn't be ok to post it all...
here is the code (markup of user control):
Code:
-+<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactForm.ascx.cs" Inherits="Controls_ContactForm" %>
<%if (false) {%>
<script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<%} %>
<style type="text/css">
.style1
{
width: 61%;
}
.style2
{
width: 235px;
}
.style3
{
height: 38px;
}
.style4
{
width: 235px;
height: 38px;
}
.style5
{
}
.style6
{
height: 38px;
width: 181px;
}
.watermark
{
font-style: italic;
color: Gray;
}
</style>
<script type="text/javascript">
function ValidatePhoneNumbers(source, args) {
var phoneHome = document.getElementById('<%= PhoneHome.ClientID %>');
var phoneBusiness = document.getElementById('<%= PhoneBusiness.ClientID %>');
if (phoneHome.value != '' || phoneBusiness.value != '') {
args.IsValid = true;
}
else {
args.IsValid = false;
}
}
</script>
<asp:UpdatePanel ID="id1" runat="server">
<ContentTemplate>
<div id="TableWrapper">
<table class="style1" runat="server" id="FormTable">
<tr>
<td colspan="3">
Contact me here:
</td>
</tr>
<tr>
<td class="style5">
Name:
</td>
<td class="style2">
<asp:TextBox ID="Name" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Name"
CssClass="ErrorMessage" Display="Dynamic" ErrorMessage="Enter Your Name">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style5">
Email Address:
</td>
<td class="style2">
<asp:TextBox ID="EmailAddress" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="EmailAddress"
CssClass="ErrorMessage" Display="Dynamic" ErrorMessage="Enter an e‑mail address">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="ConfirmEmailAddress"
CssClass="ErrorMessage" Display="Dynamic" ErrorMessage="Enter a valid e‑mail address"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style5">
Email Address Again:
</td>
<td class="style2">
<asp:TextBox ID="ConfirmEmailAddress" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ConfirmEmailAddress"
CssClass="ErrorMessage" Display="Dynamic" ErrorMessage="Confirm the e‑mail address">*</asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="EmailAddress"
ControlToValidate="ConfirmEmailAddress" CssClass="ErrorMessage" Display="Dynamic"
ErrorMessage="Retype the e‑mail address">*</asp:CompareValidator>
</td>
</tr>
<tr>
<td class="style5">
Home Phone Number:
</td>
<td class="style2">
<asp:TextBox ID="PhoneHome" runat="server"></asp:TextBox>
</td>
<td>
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidatePhoneNumbers"
CssClass="ErrorMessage" Display="Dynamic" ErrorMessage="Enter your home or business phone number"
OnServerValidate="CustomValidator1_ServerValidate">*</asp:CustomValidator>
</td>
</tr>
<tr>
<td class="style5">
Business Phone Number:
</td>
<td class="style2">
<asp:TextBox ID="PhoneBusiness" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style6">
Comments:
</td>
<td class="style4">
<asp:TextBox ID="Comments" runat="server" Height="53px" TextMode="MultiLine" Width="233px"></asp:TextBox>
</td>
<td class="style3">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Comments"
Display="Dynamic" ErrorMessage="Enter a comment" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style5">
</td>
<td class="style2">
<asp:Button ID="SendButton" runat="server" Text="Send"
onclick="SendButton_Click" />
</td>
<td>
</td>
</tr>
<tr>
<td class="style5" colspan="3">
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
CssClass="ErrorMessage" />
</td>
</tr>
</table>
</div>
<asp:Label ID="Label1" runat="server" Text="Message Sent" Visible="false"></asp:Label>
<p id="MessageSentPara" runat="server" visible="false" >than you for you message we'll get back to you later</p>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress runat="server" AssociatedUpdatePanelID="id1">
<ProgressTemplate>
<div class="PleaseWait"> <br />
wait a sec
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<script type="text/javascript">
$(function()
{
$(':input[type=text], textarea').each
(
function()
{
var newText = 'Enter your ' +
$(this).parent().prev().text().toLowerCase().trim();
$(this).attr('value', newText);
}).one('focus', function()
{
this.value = '', this.className = ''
}).addClass('watermark').css('width', '300px');
$('form').bind('submit',function(){
if(Page_IsValid){
$('#TableWrapper').slideUp(3000);
}
});
function pageload(){
$('.Attention').animate({width:'600px'},3000).animate({width:'100px'},3000).fadeOut('slow');}
</script>
and this is the markup of the contactForm:
Code:
<%@ Page Title="Contact Us" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="Contact.aspx.cs" Inherits="About_Contact" %>
<%@ Register src="~/Controls/ContactForm.ascx" tagname="ContactForm" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<uc1:ContactForm ID="ContactForm1" runat="server" />
</asp:Content>
|

September 25th, 2010, 01:44 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
ok ok ok ok, easy man.. sorry about that, it's just the code is too long I thought it wouldn't be ok to post it all...
|
If somebody asks you in this thread for the source of the page and the user control four times, and has asked similar question on pretty much each post you made, it's safe to assume it's OK to post code.
As I said before, it's almost impossible to suggest something useful without code, Asking over and over and over and over again for the code can be pretty frustrating.... ;-)
Anyway, what are those funky - and + doing there at the start of the code?
With regard to the JavaScript, you're missing a }); at the end. Change your code so it ends with this:
Code:
$('form').bind('submit', function () {
if (Page_IsValid) {
$('#TableWrapper').slideUp(3000);
}
});
});
function pageload(){
$('.Attention').animate({width:'600px'},3000).animate({width:'100px'},3000).fadeOut('slow');}
Hope this helps,
Imar
|

September 25th, 2010, 03:58 PM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
still same error
|

September 26th, 2010, 08:40 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Make sure you resolve any errors you may have (in the Error List). Then remove the user control code from the Contact page (including the Register directive) and try again.
Otherwise, I am out of ideas.
Imar
|
|
 |
|