Reputation: 2388
I have an issue when I'm trying to make my image or label visible in my web app.
using System;
using System.Linq;
using System.Web.Security;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Services;
using System.IO;
using System.Web.UI.Adapters;
public partial class Admin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Timer1_Tick(object sender, EventArgs e)
{
if (File.Exists("c:/test.pdf"))
//inform user
Console.WriteLine("File uploaded.");
Image1.visible = true;
I'm getting an error as follows:
The name 'Image1' does not exist in the current context
Any ideas here? Ive done this before without issue, but for some reason it doesn't like the image1
(which i put on my webpage and made visible = false
) nor the label which is also visible = false
.
Upvotes: 0
Views: 906
Reputation: 1495
I think the problem is that timer_tick it's not in the same thread of your web app
Upvotes: 0
Reputation: 49423
Try deleting the designer.cs file for the page and then re-open the aspx page in Design mode. Next do a full rebuild of the project and try again.
Upvotes: 0
Reputation: 919
Make sure that Image1 is declared "protected", also make sure that Image1 is the id="" for the runat="sever" control on the page.
If neither of these work, try making a trivial change to the markup to recompile the whole page class.
Upvotes: 1
Reputation: 867
had issues similar to this before, usually caused by the designer not updating after adding new control to the page. to fix i would recommend
think it should work now.
Upvotes: 0