> 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.
Steven - 07 Mar 2008 14:43 GMT
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.
On Mar 6, 9:41 pm, "Steven" <some...@somewhere.com> wrote:
> 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.
Alexey Smirnov - 08 Mar 2008 13:08 GMT
> protected string GetData()
> {
[quoted text clipped - 22 lines]
> }
> }
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
Steven - 07 Mar 2008 15:00 GMT
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();
}
On Mar 6, 9:41 pm, "Steven" <some...@somewhere.com> wrote:
> 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.