link from .html file in update panel to .aspx page fails

hi Folks:

I have a master page which contains an asp:ContentPlaceHolder tag. I am using ajax and javascript to load content into the place holder - specifically information from a standard html file. Within this conent I have a link to call a contact page which is "contact.aspx"

When "contact.aspx" is called from a link on the menu on the master page, everything works fine. When it is called from an <a href> tag in the html file which has been loaded to to the content pace holder, it fails. VS8 says that there is a server error that the "Resource cannot be found..check the url. However, the url is correct - indicates same url as indicated when click n the link from the menu in the master page.

Any assistance would be greatly appreciated... as the code is somewhat extensive I will hold off posting for the moment hoping that I am missing something simple! Otherwise I will try and post the relevant pieces.

Best regards, Dave Melnyk
d_melnykAsked:
Who is Participating?
 
d_melnykAuthor Commented:
Hi folks:

     Posted the code, but seemed to have done something to mess it up and post didn't come in. HOWEVER, did solve the problem.

Simply used  a call to javascript on the masterpage to load the url of the aspx page
        <a href="#"; onclick="callaspxpage('njhacontact.aspx')";>my link</a>

This sems to work perfectly.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hello, instead of a contant placeholder, try with a literal control, like this:
<asp:Literal Text="Your Html File text" runat="server"  />

Open in new window

0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Example:

In your code behind:

C#:
MyLiteralControl.Text = System.IO.File.ReadAllText(@"C:\MyHtmlFile.html");

Open in new window



VB.NET:
MyLiteralControl.Text = System.IO.File.ReadAllText("C:\MyHtmlFile.html")

Open in new window


In you aspx file:
<asp:Literal ID="MyLiteralControl" runat="server" />

Open in new window

Placed where you want to render it.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
d_melnykAuthor Commented:
Thanks for the reply... haven't used that method ... at this point it would be a major re-write of the entire website, yet again, ....will try and post the code I am using tomorrow.....

regards, Dave Melnyk
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hello buddy, I want to let you know the difference between the ContentPlaceHolder vs LiteralControl, the literal always is going to write to the webbrowser exactly the content of your html file, if you use, for example, a Label, inside your contentplaceholder it is going to parse your text file, so keep that in mind.
You can also use a Literal Control inside a ContentPlaceHolder too, it will work fine.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Example, if you set a label with the Text = "<" ASP.NET is going to send to the client web browser the string &lt; that is the html representation of the character <
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Sorry I mistyped that, I refer to a PlaceHolder, not ContentPlaceHolder, and by the way im wrng with the label control, it render well
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
But other controls can do that implicit conversion
0
 
d_melnykAuthor Commented:
resolved issue and works for what I need
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.