Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

HTML not generated on client

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steven - 06 Mar 2008 19:46 GMT
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
Alexey Smirnov - 06 Mar 2008 20:25 GMT
> Hello,
>   The code below will not generate the html for ImageSec.  Can anyone tell
[quoted text clipped - 21 lines]
>                     <img id="ImageSec" runat="server" src="<%# GetData2()
> %>" />

I think you have to look at the code of the GetData2() method.
Steven - 06 Mar 2008 20:41 GMT
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?

On Mar 6, 8:46 pm, "Steven" <some...@somewhere.com> wrote:
> Hello,
> The code below will not generate the html for ImageSec. Can anyone tell
[quoted text clipped - 21 lines]
> <img id="ImageSec" runat="server" src="<%# GetData2()
> %>" />

I think you have to look at the code of the GetData2() method.
Alexey Smirnov - 07 Mar 2008 08:38 GMT
> 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.
George Ter-Saakov - 06 Mar 2008 22:23 GMT
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.

On Mar 6, 8:46 pm, "Steven" <some...@somewhere.com> wrote:
> Hello,
> The code below will not generate the html for ImageSec. Can anyone tell
[quoted text clipped - 21 lines]
> <img id="ImageSec" runat="server" src="<%# GetData2()
> %>" />

I think you have to look at the code of the GetData2() method.
bruce barker - 06 Mar 2008 20:46 GMT
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)

> Hello,
>   The code below will not generate the html for ImageSec.  Can anyone tell
[quoted text clipped - 41 lines]
> Thanks,
>   Steven
Steven - 06 Mar 2008 21:00 GMT
Please forgive my ignorance (noob warning!), but how does an aspx return the
image data?

> there was no need for an update panel for this:
>
[quoted text clipped - 63 lines]
>> Thanks,
>>   Steven

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.