Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 September 25th, 2010, 11:24 AM
Authorized User
 
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?
Reply With Quote
  #2 (permalink)  
Old September 25th, 2010, 11:53 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
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 September 25th, 2010, 12:39 PM
Authorized User
 
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #4 (permalink)  
Old September 25th, 2010, 12:52 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

The error is on line 11 of the code you're not posting....

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
  #5 (permalink)  
Old September 25th, 2010, 12:57 PM
Authorized User
 
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what line 11?
and what error im not posting?
Reply With Quote
  #6 (permalink)  
Old September 25th, 2010, 01:06 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
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!

Last edited by Imar; September 25th, 2010 at 01:23 PM..
Reply With Quote
  #7 (permalink)  
Old September 25th, 2010, 01:28 PM
Authorized User
 
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>
            &nbsp;
        </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">
            &nbsp;
        </td>
        <td class="style2">
            <asp:Button ID="SendButton" runat="server" Text="Send" 
                onclick="SendButton_Click" />
        </td>
        <td>
            &nbsp;
        </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>
Reply With Quote
  #8 (permalink)  
Old September 25th, 2010, 01:44 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
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
  #9 (permalink)  
Old September 25th, 2010, 03:58 PM
Authorized User
 
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

still same error
Reply With Quote
  #10 (permalink)  
Old September 26th, 2010, 08:40 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
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
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
Dynamic Add User Control To The Tab Control cheer ASP.NET 3.5 Basics 1 February 25th, 2009 10:48 PM
Error adding Report Viewer Control in Web User Con everest ASP.NET 2.0 Professional 0 January 29th, 2008 07:24 PM
Add Windows User control in Web User Control agarwalvidhu C# 0 March 30th, 2006 01:17 AM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM
User Control Syntax error g2000 BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 December 22nd, 2005 06:04 PM



All times are GMT -4. The time now is 11:30 AM.


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