Showing posts with label display. Show all posts
Showing posts with label display. Show all posts

Monday, March 26, 2012

This is killing me... need to display custom HTML from remote site to a calling site

Ok, I hope someone has done this or can help me here as I'm having trouble finding what I need.

What I want to do is allow users to include a javascript file in their website that will go out and pull data from my site / db and display it on their website. What will happen is they pass over some specific information that indicates what they want returned and then I'll serve it to their website where it displays in a naturally embedded format and looks like it's part of their own content.

An example of what I want to do is the same as the following:

 <div style="padding-left:10px; padding-right:10px;">
<asp:PlaceHolder ID="plcContent"runat="Server">
<script language="javascript" src="http://pics.10026.com/?src=http://www.datafeedfile.com/dff_jsthrow.php?affid=1001&script=search_index&style=12"></script>
</asp:PlaceHolder>
</div>

What the above line does is display contents (full HTML) from data feed file onto a webpage (shopping content), but doesn't actually render the full HTML to the webpage (if you right-click and view source). I want to do the same thing where someone calls a .ASPX or .ASMX page / service and I return (or serve) the HTML content. So, a call to my app may look like:

 <div style="padding-left:10px; padding-right:10px;">
<asp:PlaceHolder ID="plcContent"runat="Server">
<script language="javascript" src="http://pics.10026.com/?src=http://www.mysite.com/contentsource.aspx?affid=1001&type=X"></script>
</asp:PlaceHolder>
</div>
The contentsource.aspx page will then return (or display) a listing of products from my website on the calling website.  

Can that be done in ASP.NET 2.0? Any help much appreciated as I've been searching for a couple days (and many many hours of trial and error) with no luck. Thanks!

Hi,

Try to use IFRAME, see http://www.w3schools.com/tags/tag_iframe.asp


Add this to your page (and remove html from the ASPX that shouldn't be there, such as <body>, <head> etc.)

protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb=new StringBuilder();
StringWriter sw =new StringWriter(sb);
HtmlTextWriter hw =new HtmlTextWriter(sw);
base.Render(hw);

Response.Clear();
Response.ContentType ="text/javascript";

string html =string.Format("window.document.write({0});",Enquote(sb.ToString()));
writer.Write(html);

}

/// FUNCTION Enquote Public Domain 2002 JSON.org
/// @.author JSON.org
/// @.version 0.1
/// Ported to C# by Are Bjolseth, teleplan.no
public static string Enquote(string s)
{
if (s ==null || s.Length == 0)
{
return"\"\"";
}
char c;
int i;
int len = s.Length;
StringBuilder sb =new StringBuilder(len + 4);
string t;

sb.Append('"');
for (i = 0; i < len; i += 1)
{
c = s[i];
if ((c =='\\') || (c =='"') || (c =='>'))
{
sb.Append('\\');
sb.Append(c);
}
else if (c =='\b')
sb.Append("\\b");
else if (c =='\t')
sb.Append("\\t");
else if (c =='\n')
sb.Append("\\n");
else if (c =='\f')
sb.Append("\\f");
else if (c =='\r')
sb.Append("\\r");
else
{
if (c <' ')
{
//t = "000" + Integer.toHexString(c);
string tmp =new string(c, 1);
t ="000" +int.Parse(tmp, System.Globalization.NumberStyles.HexNumber);
sb.Append("\\u" + t.Substring(t.Length - 4));
}
else
{
sb.Append(c);
}
}
}
sb.Append('"');
return sb.ToString();
}


Thanks, but that doesn't quit work for what I want. I just want users to be able to do it via a javascript call like in the example I provided. IFrames are kinda ugly, clunky, and not really something I would want to ask users to drop into their sites. I appreciate the reply though!


guntem,

That's exactly what I needed! Very very much appreciated as you've saved me much time and frustration.

David

Thursday, March 22, 2012

Thread

Hai Experts,
I have one aspx Page that updates lots of data to Active
Directory.This Part is done, But i need to display the status of
updation(That is How Many Entries are updated) for certain Period of time
and how many entries are pending to update. Is it possible through Threads,
can anyone please suggest me what to do.

Thanks,
Rajeev.I have done something similar, but it involved upload status instead. But,
I believe the concepts are similar. You want to display % complete, right?
It involved using an IFRAME (this showed the % complete). The main page
continued to process while the page in the IFRAME refreshed every couple of
seconds to determine what the status was.

I built an object that processed the upload and provided a % complete. The
page displaying the status complete interrogated that object for its status
while the other page did the work. I used threading and chunking (for the
upload) in this solution. I believe you could do something similar.

Sincerely,
John Swanagon
Sr. Software Engineer, Avaya Labs
Avaya Inc.
jmswanagon@.avaya.com
"RajeevSekar" <RajeevSekar@.force10networks.comwrote in message
news:uib3CF%23rGHA.4032@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Hai Experts,
I have one aspx Page that updates lots of data to Active
Directory.This Part is done, But i need to display the status of
updation(That is How Many Entries are updated) for certain Period of time
and how many entries are pending to update. Is it possible through
Threads, can anyone please suggest me what to do.
>
Thanks,
Rajeev.
>