HTML not generated on client

S

Steven

Hello,
The code below will not generate the html for ImageSec. Can anyone tell
me why?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynCtls.aspx.cs"
Inherits="DynCtls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Viewer</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div align="center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<img id="ImagePrim" runat="server" src="<%# GetData()
%>" />
<img id="ImageSec" runat="server" src="<%# GetData2()
%>" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

<script language="javascript" type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
setTimeout('Update()', 10000);

function Update()
{
prm._doPostBack('UpdatePanel1', '');
setTimeout('Update()', 10000);
}
</script>

Thanks,
Steven
 
G

Guest

Hello,
  The code below will not generate the html for ImageSec.  Can anyone tell
me why?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynCtls.aspx..cs"
Inherits="DynCtls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Viewer</title>
</head>
<body>
    <form id="Form1" method="post" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div align="center">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
                <ContentTemplate>
                    <img id="ImagePrim" runat="server" src="<%# GetData()
%>" />
                    <img id="ImageSec" runat="server" src="<%# GetData2()
%>" />

I think you have to look at the code of the GetData2() method.
 
S

Steven

GetData2() is a function that returns the same string that GetData()
returns. GetData() sets a property with it's return string, GetData2() gets
that property. It appears to be working in the codebehind; I have verified
that the strings are exactly the same. I don't want the code to execute
GetData() twice. Should not this work?


Hello,
The code below will not generate the html for ImageSec. Can anyone tell
me why?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynCtls.aspx.cs"
Inherits="DynCtls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Viewer</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div align="center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<img id="ImagePrim" runat="server" src="<%# GetData()
%>" />
<img id="ImageSec" runat="server" src="<%# GetData2()
%>" />

I think you have to look at the code of the GetData2() method.
 
B

bruce barker

there was no need for an update panel for this:

<img id="ImagePrim" src="GetData.aspx?id=prim" />
<img id="ImageSec" runat="server" src="GetData.aspx?id=sec" />
<script>
var ic=0;
function Update()
{
document.getElementById('ImagePrim').src =
'getdata.aspx?id=prim&r=' + (++ic);
document.getElementById('ImageSec').src =
'getdata.aspx?id=sec&r=' + (++ic);
}
</script>

where getdata.aspx either returns the image data, or redirects to the image
file.


-- bruce (sqlwork.com)
 
S

Steven

Please forgive my ignorance (noob warning!), but how does an aspx return the
image data?
 
G

George Ter-Saakov

you better look at HTML that was generated...
Is there <img id="ImageSec"..>

Very often tag is there but because you forgot to close the quote somewhere
in HTML it's not visible.....


George.


Hello,
The code below will not generate the html for ImageSec. Can anyone tell
me why?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynCtls.aspx.cs"
Inherits="DynCtls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Viewer</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div align="center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<img id="ImagePrim" runat="server" src="<%# GetData()
%>" />
<img id="ImageSec" runat="server" src="<%# GetData2()
%>" />

I think you have to look at the code of the GetData2() method.
 
G

Guest

GetData2() is a function that returns the same string that GetData()
returns.  GetData() sets a property with it's return string, GetData2() gets
that property.  It appears to be working in the codebehind; I have verified
that the strings are exactly the same.  I don't want the code to execute
GetData() twice.  Should not this work?

Steven, when your code of the GetData2() function does not generate
the html for ImageSec, you should check the function. If you cannot
find the error, post the code of the function here.
 
S

Steven

protected string GetData()
{
try
{
Session["LastImage"] = Session["SaveImage"];
LastImage = Session["LastImage"].ToString();

string url = Session["ImageUrl"].ToString();
Session["SaveImage"] = Session["ImageUrl"];
string szUrl = url.Replace("~", @"http://" +
Request.ServerVariables["HTTP_HOST"]);
ImageUrl2 = szUrl;
return szUrl;
}
catch (Exception e)
{
RecordError(e, EventLogEntryType.Error);
return null;
}
finally
{
//Delete the previous images
Thread t = new Thread(new ThreadStart(DeleteLastFile));
t.Start();
}
}

protected string GetData2()
{
return ImageUrl2;
}

private static string _ImageUrl2;
public static string ImageUrl2
{
get { return _ImageUrl2; }
set { _ImageUrl2 = value; }
}

FWIW, I have verified that the returns are correct by setting breakpoints.

GetData2() is a function that returns the same string that GetData()
returns. GetData() sets a property with it's return string, GetData2()
gets
that property. It appears to be working in the codebehind; I have verified
that the strings are exactly the same. I don't want the code to execute
GetData() twice. Should not this work?

Steven, when your code of the GetData2() function does not generate
the html for ImageSec, you should check the function. If you cannot
find the error, post the code of the function here.
 
S

Steven

Alexey,
Perhaps something else that may be relevant. In Page_Load , the code sets
the visible properties of the ImagePrim and ImageSec to either true or
false, depending on which image is to be displayed.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["ImageUrl"] =
ConfigurationManager.AppSettings["ImageUrl"];

string f = GetExistingFile();
Session["ImageUrl"] = Session["ImageUrl"] + f;

this.ImagePrim.Visible = true;
this.ImageSec.Visible = false;

Session["flag"] = null;
Session["Updating"] = 1;

StartFileSystemWatcher();
}

if (Session["flag"] != null)
{
switch (Convert.ToInt32(Session["flag"]))
{
case 0:
this.ImagePrim.Visible = true;
this.ImageSec.Visible = false;
Session["flag"] = 1;
break;
case 1:
this.ImageSec.Visible = true;
this.ImagePrim.Visible = false;
Session["flag"] = 0;
break;
default:
break;
}
}
else
{
Session["flag"] = 1;
}

Page.DataBind();

}

GetData2() is a function that returns the same string that GetData()
returns. GetData() sets a property with it's return string, GetData2()
gets
that property. It appears to be working in the codebehind; I have verified
that the strings are exactly the same. I don't want the code to execute
GetData() twice. Should not this work?

Steven, when your code of the GetData2() function does not generate
the html for ImageSec, you should check the function. If you cannot
find the error, post the code of the function here.
 
G

Guest

    protected string GetData()
    {
        try
        {
            Session["LastImage"] = Session["SaveImage"];
            LastImage = Session["LastImage"].ToString();

            string url = Session["ImageUrl"].ToString();
            Session["SaveImage"] = Session["ImageUrl"];
            string szUrl = url.Replace("~", @"http://" +
Request.ServerVariables["HTTP_HOST"]);
            ImageUrl2 = szUrl;
            return szUrl;
        }
        catch (Exception e)
        {
            RecordError(e, EventLogEntryType.Error);
            return null;
        }
        finally
        {
            //Delete the previous images
            Thread t = new Thread(new ThreadStart(DeleteLastFile));
            t.Start();
        }
    }

Hi Steven

I think I see where the problem is. HTML Server Control cannot be
declared like you did. Either use a regular html <img> tag without
runat="server" and with src="<%= GetData() %>", or in case you need a
server control, set the src property in the code-behind, for example:

ImagePrim.src = GetData();
ImageSec.src = GetData2();

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top