Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="L_PaperSet.aspx.cs" Inherits="Lib_Web.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style7
        {
            width: 100%;
        }
        .style8
        {
            width: 228px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table class="style7">
        <tr>
            <td class="style8">
                &nbsp;</td>
            <td>
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>

                        <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick">
                        </asp:Timer>
                        <asp:Image ID="Image1" runat="server" />
                    </ContentTemplate>


                </asp:UpdatePanel>

            </td>
        </tr>
        <tr>
            <td class="style8">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
</asp:Content>


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Lib_Web
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                NewMethod();

            }
        }

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            NewMethod();
        }

        private void NewMethod()
        {
            Random rand = new Random();
            int i = rand.Next(1, 4);
            Image1.ImageUrl = "~/L_pics/" + i.ToString() + ".jpg";
        }
    }
}


additional information copied from comment below
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1061: 'ASP.l_paperset_aspx' does not contain a definition for 'Timer1_Tick' and no extension method 'Timer1_Tick' accepting a first argument of type 'ASP.l_paperset_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 23:                     <contenttemplate>
Line 24:                     
Line 25:                         <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick">
Line 26:                         </contenttemplate>
Line 27:                         <asp:Image ID="Image1" runat="server" />
Posted
Updated 15-Nov-14 10:10am
v3
Comments
Tomas Takac 15-Nov-14 5:22am    
What's the error?
Nitin Guralwar 15-Nov-14 8:36am    
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'ASP.l_paperset_aspx' does not contain a definition for 'Timer1_Tick' and no extension method 'Timer1_Tick' accepting a first argument of type 'ASP.l_paperset_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 23: <contenttemplate>
Line 24:
Line 25: <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick">
Line 26:
Line 27: <asp:Image ID="Image1" runat="server" />
Tomas Takac 15-Nov-14 11:11am    
It's better to update your question with the additional information. Next time use the "improve" button. Cheers
MJ2014 15-Nov-14 5:33am    
What's the error ?
Nitin Guralwar 15-Nov-14 8:36am    
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'ASP.l_paperset_aspx' does not contain a definition for 'Timer1_Tick' and no extension method 'Timer1_Tick' accepting a first argument of type 'ASP.l_paperset_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 23: <contenttemplate>
Line 24:
Line 25: <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick">
Line 26:
Line 27: <asp:Image ID="Image1" runat="server" />

in your aspx page code file is CodeBehind="L_PaperSet.aspx.cs" but you may have renamed it to something else. give the correct name of WebForm2 class cs file, then this error will be vanished.
 
Share this answer
 
Comments
Nitin Guralwar 15-Nov-14 9:46am    
Please where exactly i have make change
DamithSL 15-Nov-14 10:07am    
what is your .cs file name of Timer1_Tick containing file?
Nitin Guralwar 15-Nov-14 13:31pm    
i found new solution
i changed CodeBehind to CodeFile in my aspx page
Nitin Guralwar 15-Nov-14 10:25am    
L_PaperSet.aspx.cs
Have you tried to make the method public?

C#
protected void Timer1_Tick(object sender, EventArgs e)
public void Timer1_Tick(object sender, EventArgs e)
{
    NewMethod();
}
 
Share this answer
 
Comments
Nitin Guralwar 15-Nov-14 13:31pm    
i found new solution
i changed CodeBehind to CodeFile in my aspx page
I had exactly the same problem, and realised it was a... errrm.. client problem.

I had asked them to add some code to their .aspx file, and also to their .aspx.cs file (which contained the timer_tick function).

They did this... it all worked fine and ran locally... but then, in Visual Studio 2015, they had decided to right click on just that particular .aspx file, and just publish that file.

So, what happened ?

The .aspx file successfully deployed to their IIS server, but the C# code in their .cs file had been compiled into a .dll file in their bin directory, but they hadn't published that.

Yeah... I know....

So, if you do find that your namespaces do match exactly, but you're still getting this error... well... check your bin directory....!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900