Showing posts with label pages. Show all posts
Showing posts with label pages. Show all posts

Monday, March 26, 2012

trouble dynamically loading content to my website

I am trying to dynamically load other pages into one main page on my website kinda of like a "wapper page." I was told to use PlaceHolders to do so but can't get the code to work. The link I am following is http://www.ftponline.com/vsm/2002_10/online/hottips/gusmano/ . I did everything according to the article but I get an error.
My code looks like this:
default.aspx:

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
string page = Request.QueryString.Get("page");
PlaceHolder1.Controls.Clear();
if (page == null)
PlaceHolder1.Controls.Add(LoadControl("default" + ".ascx"));
else
{
PlaceHolder1.Controls.Add(LoadControl(page + ".ascx"));
}
}
</script>
<html>
<head></head>
<body>
.....
</body>
</html
and the default.ascx is just a regular html page including a flash document:

<html>
<head>
<title>Main</title>
</head>
<body>
<center>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="640" height="480" id="main" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="main.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<embed src="http://pics.10026.com/?src=main.swf" quality="high" bgcolor="#000000" width="640" height="480"
swLiveConnect="true" NAME="main.swf" name="main" align="middle"
allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</center>
</body>
</html
The error I get is :
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'PlaceHolder1' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 6: {
Line 7: string p = Request.QueryString.Get("page");
Line 8: PlaceHolder1.Controls.Clear();
Line 9: if (page == null)
Line 10: PlaceHolder1.Controls.Add(LoadControl("default" + ".ascx"));

Source File: F:\WWW\default.aspx Line: 8

What am I doing wrong? Also where do I add code into my default.aspx page to tell it where to load the other pages. As far as I can see, it just knows the load the a page but I can't figure out how it knows where to load it. I really appreciate all your help. Thanks a lot.What this is saying is that your placeholder1 does not exsist. Check your code to ensure you are using the corredt spelling for placeholder 1.
check out this maybe this can help

http://dotnet247.com/247reference/msgs/51/256296.aspx
I copied and pasted my code from my file. I really have no idea why it is saying that it doesnt exist. Do I have to import a library??

Thursday, March 22, 2012

Trouble with Multiple Master Pages in ASP.NET 2.0

I am writing an ASP.NET 2.0 application that uses more than one master page.
Currently, there are two pages, Freedom1.master and Freedom2.master. I have
no problems with Freedom1.master. However, I am having problems with
Freedom2.master.
The first problem is I sometimes get the following error when I build the
site.
The type 'Freedom2' exists in both
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_ammoxc8r.dll' and
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_fxnhzrev.dll'
The error appears for each page built using Freedom2.master.
The second problem occurs at runtime for statments like the following.
protected void Page_Load(object sender, EventArgs e)
{
Freedom2 master = (Freedom2)Master;
master.Page.Header.Title = "Freedom LINC Registration";Your code looks a bit confusing, you seem to be declaring an object called
master of type freedom2 and initialising it with the value contained in it's
self cast as a type freedom2. What are trying to do with that code?
"EagleRed@.HighFlyingBirds.com" wrote:

> I am writing an ASP.NET 2.0 application that uses more than one master pag
e.
> Currently, there are two pages, Freedom1.master and Freedom2.master. I ha
ve
> no problems with Freedom1.master. However, I am having problems with
> Freedom2.master.
> The first problem is I sometimes get the following error when I build the
> site.
> The type 'Freedom2' exists in both
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_ammoxc8r.dll' and
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_fxnhzrev.dll'
> The error appears for each page built using Freedom2.master.
> The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
> .
> .
> .
> The error message states that there is a failure to cast an infinite integ
er
> to the type, Freedom2.
> What is going on? How do I address these issues? These problems are
> intermittent but significant.
> Any input is appreciated.
> Thank you,
> EagleRed
>
>
In article <31042077-F0EC-49B9-90D7-C782AEAE5187@.microsoft.com>,
"EagleRed@.HighFlyingBirds.com"
<EagleRedHighFlyingBirdscom@.discussions.microsoft.com> writes
>I am writing an ASP.NET 2.0 application that uses more than one master page
.
>Currently, there are two pages, Freedom1.master and Freedom2.master. I hav
e
>no problems with Freedom1.master. However, I am having problems with
>Freedom2.master.
>The first problem is I sometimes get the following error when I build the
>site.
>The type 'Freedom2' exists in both
>'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_ammoxc8r.dll' and
>'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_fxnhzrev.dll'
>The error appears for each page built using Freedom2.master.
Try stopping the server, then deleting the files in the temporary
ASP.NET files folder. Then restart the server and try again. I have seen
this cure this problem.

>The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
<snip>
Why are you doing it this way? Title is a standard property of the page,
even when master pages are used, so you can simply do...
Page.Header.Title = "Freedom LINC Registration";
More to the point, if you are setting the title to a fixed string, just
set it in the Page directive of the .aspx file instead of in code. As I
understand it, this gets compiled with the page, so will be a teensy
weensy bit faster too.
HTH
Alan Silver
(anything added below this line is nothing to do with me)
Needed or non needed code I have the same problem:
I usually cast master in order to hide or show some components / parts
of page. Anyhow why I want to cast master page is not an issue here.
The issue is why this cast may or may not fail.
My findings are that:
- I assume that in place compilation creates 2 copies of assembly,
- killing w3wp usually helps (if it doesn't delete asp.net tmp
folders/files),
- it may happens only after some compilation was made (after changes in
files, etc...).
I belive that, precompiled deployment is safer regarding this
problem...
I would like some more info about that problem.
bye,
D

Trouble with Multiple Master Pages in ASP.NET 2.0

I am writing an ASP.NET 2.0 application that uses more than one master page.
Currently, there are two pages, Freedom1.master and Freedom2.master. I have
no problems with Freedom1.master. However, I am having problems with
Freedom2.master.

The first problem is I sometimes get the following error when I build the
site.

The type 'Freedom2' exists in both
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _ammoxc8r.dll' and
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _fxnhzrev.dll'

The error appears for each page built using Freedom2.master.

The second problem occurs at runtime for statments like the following.

protected void Page_Load(object sender, EventArgs e)
{

Freedom2 master = (Freedom2)Master;
master.Page.Header.Title = "Freedom LINC Registration";Your code looks a bit confusing, you seem to be declaring an object called
master of type freedom2 and initialising it with the value contained in it's
self cast as a type freedom2. What are trying to do with that code?

"EagleRed@.HighFlyingBirds.com" wrote:

> I am writing an ASP.NET 2.0 application that uses more than one master page.
> Currently, there are two pages, Freedom1.master and Freedom2.master. I have
> no problems with Freedom1.master. However, I am having problems with
> Freedom2.master.
> The first problem is I sometimes get the following error when I build the
> site.
> The type 'Freedom2' exists in both
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _ammoxc8r.dll' and
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _fxnhzrev.dll'
> The error appears for each page built using Freedom2.master.
> The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
> .
> .
> .
> The error message states that there is a failure to cast an infinite integer
> to the type, Freedom2.
> What is going on? How do I address these issues? These problems are
> intermittent but significant.
> Any input is appreciated.
> Thank you,
> EagleRed
>
In this case I am changing the title of the page with the statement,

master.Page.Header.Title = "Freedom LINC Registration";

There are other occasions I wish to access properties on the master page
from the aspx page that uses it. For example to change the href on a link.

My problem is that I have multiple master pages, e.g. Freedom1. All inherit
from the Master class. Freedom1 derived pages work fine but I am getting
intermittent compilation or runtime errors with Freedom2.

Thanks,
EagleRed

"EagleRed@.HighFlyingBirds.com" wrote:

> I am writing an ASP.NET 2.0 application that uses more than one master page.
> Currently, there are two pages, Freedom1.master and Freedom2.master. I have
> no problems with Freedom1.master. However, I am having problems with
> Freedom2.master.
> The first problem is I sometimes get the following error when I build the
> site.
> The type 'Freedom2' exists in both
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _ammoxc8r.dll' and
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _fxnhzrev.dll'
> The error appears for each page built using Freedom2.master.
> The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
> .
> .
> .
> The error message states that there is a failure to cast an infinite integer
> to the type, Freedom2.
> What is going on? How do I address these issues? These problems are
> intermittent but significant.
> Any input is appreciated.
> Thank you,
> EagleRed
>
In article <31042077-F0EC-49B9-90D7-C782AEAE5187@.microsoft.com>,
"EagleRed@.HighFlyingBirds.com"
<EagleRedHighFlyingBirdscom@.discussions.microsoft.c om> writes
>I am writing an ASP.NET 2.0 application that uses more than one master page.
>Currently, there are two pages, Freedom1.master and Freedom2.master. I have
>no problems with Freedom1.master. However, I am having problems with
>Freedom2.master.
>The first problem is I sometimes get the following error when I build the
>site.
>The type 'Freedom2' exists in both
>'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
>Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _ammoxc8r.dll' and
>'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
>Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _fxnhzrev.dll'
>The error appears for each page built using Freedom2.master.

Try stopping the server, then deleting the files in the temporary
ASP.NET files folder. Then restart the server and try again. I have seen
this cure this problem.

>The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
<snip
Why are you doing it this way? Title is a standard property of the page,
even when master pages are used, so you can simply do...

Page.Header.Title = "Freedom LINC Registration";

More to the point, if you are setting the title to a fixed string, just
set it in the Page directive of the .aspx file instead of in code. As I
understand it, this gets compiled with the page, so will be a teensy
weensy bit faster too.

HTH

--
Alan Silver
(anything added below this line is nothing to do with me)
Needed or non needed code I have the same problem:

I usually cast master in order to hide or show some components / parts
of page. Anyhow why I want to cast master page is not an issue here.
The issue is why this cast may or may not fail.
My findings are that:
- I assume that in place compilation creates 2 copies of assembly,
- killing w3wp usually helps (if it doesn't delete asp.net tmp
folders/files),
- it may happens only after some compilation was made (after changes in
files, etc...).

I belive that, precompiled deployment is safer regarding this
problem...

I would like some more info about that problem.

bye,
D

Tuesday, March 13, 2012

Troubles sending email with System.Net.Mail (ASP.NET 2.0)

Hi All,

I am having difficulties sending an email from a web page that I created to my own email. This particular web pages is suppose to be a feedback form where people can leave feedback about the site and it should send the message to my email. The Exception message I get is: "Failure sending mail." Here is the piece of code I use to handle the email sending. If anyone can shed some light on this issue, it would be greatly appreciated :)

protectedvoid btnSubmit_Click(object sender,EventArgs e)

{

try

{

SmtpClient emailClient =newSmtpClient();

MailMessage email =newMailMessage();

emailClient.Host ="localhost";

emailClient.Port = 25;

email.To.Add(newMailAddress("kevintrinh.n@dotnet.itags.org.gmail.com"));

email.From =newMailAddress(txtEmail.Text);

email.Subject ="Enquiry";

email.Body ="Testing";

email.IsBodyHtml =false;

emailClient.Send(email);

}

catch(Exception ex)

{

Response.Write(ex.Message);

}

}

Cheers guys

Check the SMTP logs to start troubleshooting this.

Jeff


You'll need more detailed error info to get help.

One quick thing to check, is antivirus software on your computer blocking your code from sending email?


I have a feedback page, too, and it works great. Here's my code:

The Click Event:

public void SendMail_Click(object sender, EventArgs e)

{

SendMail();

}


public void SendMail()
{
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress(WebConfigurationManager.AppSettings["DefaultMailFrom"], "Internet User: " + txtName.Text);
mail.To.Add(WebConfigurationManager.AppSettings["DefaultMailTo"]);
if (txtEmail.Text.Trim() != "")
mail.ReplyTo = new MailAddress(txtEmail.Text.Trim());

//set the content
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text;
mail.Body += "\n\nReferring page: " + lnkReferrerF.NavigateUrl;

//send the message
SmtpClient smtp = new SmtpClient(WebConfigurationManager.AppSettings["DefaultMailServer"]);
smtp.Send(mail);
}

And then under <AppSettings> in the web.config file I have:

<add key="DefaultMailFrom" value="mailer@.site.com" />
<add key="DefaultMailReplyTo" value="david@.site.com" />
<add key="DefaultMailTo" value="david@.site.com" />

<add key="DefaultMailServer" value="mailserver name" />

Hope this helps.


Kevin-

If you're currently trying to run this on your local PC, make sure you have an SMTP server running on your box. Open up the IIS Configuration in your Control Panel > Administrative Tools and make sure the Default SMTP Virtual Server is started.

Thanks~


Hi everyone,

Thanks for all the insight...I really appreciate it. I will take a look at all your suggestions and follow up. Thanks again guys :)

Cheers


Dear Friend,

Also check out if you are running any anti virus scanners. Sometimes those applications blocks the port for sending out the emails. You may need to configure them to send out the emails.


tanglin05:

Kevin-

If you're currently trying to run this on your local PC, make sure you have an SMTP server running on your box. Open up the IIS Configuration in your Control Panel > Administrative Tools and make sure the Default SMTP Virtual Server is started.

Thanks~

Hi Todd,

I think this is my problem. I've taken a look on the net and all the tutorials explain the procedure to configure the virtual smtp server for all windows other than VISTA. Just wondering if you know how to configure the settings on vista or if you/anyone know of any links that may point me in the right direction?
In the mean time I will continue looking for explanations online :)

Thanks mate.


Kevin-

I'm away from my desktop right now, so I don't have Vista handy. Based on these posts I found on the Net, it appears SMTP may not be in Vista (?!):

http://tfl09.blogspot.com/2007/03/smtp-in-vista-or-not.html

http://weblogs.asp.net/steveschofield/archive/2006/12/19/iis7-post-23-vista-and-smtp-server-where-is-it.aspx

I can't verify this right now, so if anyone knows otherwise please correct me. The links I provided have references to shareware SMTP servers that you can install to solve your problem, so this may help you get on your way.

Thanks~


Todd you're a champ mate...I downloaded a free smtp server and it sends nowBig Smile');" title="Big Smile -Big Smile">

Just some tips for anyone else with a similar problem. If you are trying to send emails from you local machine, make sure the ISP you are going through does not block port 25 (else your emails cannot be sent). I found that I could send from uni but I couldn't send from home (for the above reason)

If everything seems ok with your code and server setup however you do not receive any emails.....check your SPAM folder!! (This is also what happened to me; spent 2 long hours trying to work out why I wasn't receiving any emails!)

I found the following SMTP server application to be the most useful one out there as it allows you to test whether port 25 is open. You can download the free 30day trial here1st SMTP Server

Hope this helps anyone facing the same email problems as I didSmile');" title="Smile -Smile">

Thanks again everyone for your helpYes');" title="Yes -Yes">