473,588 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having trouble calling code-behind functions from within an .aspx page

Hi folks,

I am have been trying to solve this problem for quite some time now and
would appreciate any advice. I have been trying to call a code-behind
function that is defined in my aspx.cs from within a DataList
<ItemTemplate > block using the <%# %> syntax. I would not have written
here if I had not spent over 6 hours trying to find a solution to this
problem again any advice is greatly appreciated.

I have included a code snippet below of the HTML code inside my .aspx
page. This code is found between the <ItemTemplate ></ItemTemplate>
tags. (I have excluded the rest of the code to reduce spam; if you
need more information please let me know).

<asp:HyperLin k ID="imgCovertRe sult"
NavigateUrl="In terviewQuestion s.aspx?catId=<% #
DataBinder.Eval (Container.Data Item, "cat_id") %>"
ImageUrl="<%# GetResultImage( DataBinder.Eval (Container.Data Item,
"cat_id"), DataBinder.Eval (Container.Data Item, "covert_cutpoin t_min"))
%>">
</asp:HyperLink>

Here is a small snippet of the .aspx.cs file that is associated with
the page. I have included a header to show class creation and the
function definition that resides within.
namespace Company1.WebUI. Admin
{
/// <summary>
/// Display Report Summaries for general users and display an Invalid
Surveys grid for Admin users
/// </summary>
public class AtRiskCategorie s :
Company1.WebUI. Admin.UICompone nts.PageBase
{

..... more code ....

public string GetResultImage( int cat_id, int covert_cutpoint )
{
string sql;
DataSet ds;
int score;
......more code...
}
When I compile everything I get no compiler erros but when I then go to
the page I get this error msg,

Compiler Error Message: CS0103: The name 'GetResultImage ' does not
exist in the current context

If I remove the line <%#
GetResultImage( DataBinder.Eval (Container.Data Item, "cat_id"),
DataBinder.Eval (Container.Data Item, "covert_cutpoin t_min")) %> it
works like a charm, but that was expected. (Note: I do properly
populate the DataList with a valid DataSet and the results are correct
when the line above is omitted).

I have tried so hard to figure this out I am just hitting my head
against the wall. I have tried everything I can think of. I have a
book that tells me that it is possible to call a code-behind function
like this within a DataList (and my syntax above is almost exact). Any
advice or suggestions are greatly appreciated. Thank you for reading
this!

Best Regards,

Mike P

Apr 5 '06 #1
2 3540
Looks like an overloading/unboxing issue. It's looking for
a different GetResultImage because of the mismatched
parameters. What if you explicitly convert the Eval
results to int? Unboxing can't be implicit.

<mi************ @yahoo.com> wrote in message
news:11******** *************@t 31g2000cwb.goog legroups.com...
Hi folks,

I am have been trying to solve this problem for quite some time now and
would appreciate any advice. I have been trying to call a code-behind
function that is defined in my aspx.cs from within a DataList
<ItemTemplate > block using the <%# %> syntax. I would not have written
here if I had not spent over 6 hours trying to find a solution to this
problem again any advice is greatly appreciated.

I have included a code snippet below of the HTML code inside my .aspx
page. This code is found between the <ItemTemplate ></ItemTemplate>
tags. (I have excluded the rest of the code to reduce spam; if you
need more information please let me know).

<asp:HyperLin k ID="imgCovertRe sult"
NavigateUrl="In terviewQuestion s.aspx?catId=<% #
DataBinder.Eval (Container.Data Item, "cat_id") %>"
ImageUrl="<%# GetResultImage( DataBinder.Eval (Container.Data Item,
"cat_id"), DataBinder.Eval (Container.Data Item, "covert_cutpoin t_min"))
%>">
</asp:HyperLink>

Here is a small snippet of the .aspx.cs file that is associated with
the page. I have included a header to show class creation and the
function definition that resides within.
namespace Company1.WebUI. Admin
{
/// <summary>
/// Display Report Summaries for general users and display an Invalid
Surveys grid for Admin users
/// </summary>
public class AtRiskCategorie s :
Company1.WebUI. Admin.UICompone nts.PageBase
{

.... more code ....

public string GetResultImage( int cat_id, int covert_cutpoint )
{
string sql;
DataSet ds;
int score;
.....more code...
}
When I compile everything I get no compiler erros but when I then go to
the page I get this error msg,

Compiler Error Message: CS0103: The name 'GetResultImage ' does not
exist in the current context

If I remove the line <%#
GetResultImage( DataBinder.Eval (Container.Data Item, "cat_id"),
DataBinder.Eval (Container.Data Item, "covert_cutpoin t_min")) %> it
works like a charm, but that was expected. (Note: I do properly
populate the DataList with a valid DataSet and the results are correct
when the line above is omitted).

I have tried so hard to figure this out I am just hitting my head
against the wall. I have tried everything I can think of. I have a
book that tells me that it is possible to call a code-behind function
like this within a DataList (and my syntax above is almost exact). Any
advice or suggestions are greatly appreciated. Thank you for reading
this!

Best Regards,

Mike P

Apr 6 '06 #2
Although I'm puzzled why you're not getting an
overload error instead. So looks like even
before it gets to that it's not seeing any GetResultImage.
Are you sure the Inherts on the page is set to the
namespace and class of the codebehind?
And if there is an src in the page directive, try
removing it.

Does it work if you move the method out of the
code-behind into the page itself, in a server-side
script block?
<mi************ @yahoo.com> wrote in message
news:11******** *************@t 31g2000cwb.goog legroups.com...
Hi folks,

I am have been trying to solve this problem for quite some time now and
would appreciate any advice. I have been trying to call a code-behind
function that is defined in my aspx.cs from within a DataList
<ItemTemplate > block using the <%# %> syntax. I would not have written
here if I had not spent over 6 hours trying to find a solution to this
problem again any advice is greatly appreciated.

I have included a code snippet below of the HTML code inside my .aspx
page. This code is found between the <ItemTemplate ></ItemTemplate>
tags. (I have excluded the rest of the code to reduce spam; if you
need more information please let me know).

<asp:HyperLin k ID="imgCovertRe sult"
NavigateUrl="In terviewQuestion s.aspx?catId=<% #
DataBinder.Eval (Container.Data Item, "cat_id") %>"
ImageUrl="<%# GetResultImage( DataBinder.Eval (Container.Data Item,
"cat_id"), DataBinder.Eval (Container.Data Item, "covert_cutpoin t_min"))
%>">
</asp:HyperLink>

Here is a small snippet of the .aspx.cs file that is associated with
the page. I have included a header to show class creation and the
function definition that resides within.
namespace Company1.WebUI. Admin
{
/// <summary>
/// Display Report Summaries for general users and display an Invalid
Surveys grid for Admin users
/// </summary>
public class AtRiskCategorie s :
Company1.WebUI. Admin.UICompone nts.PageBase
{

.... more code ....

public string GetResultImage( int cat_id, int covert_cutpoint )
{
string sql;
DataSet ds;
int score;
.....more code...
}
When I compile everything I get no compiler erros but when I then go to
the page I get this error msg,

Compiler Error Message: CS0103: The name 'GetResultImage ' does not
exist in the current context

If I remove the line <%#
GetResultImage( DataBinder.Eval (Container.Data Item, "cat_id"),
DataBinder.Eval (Container.Data Item, "covert_cutpoin t_min")) %> it
works like a charm, but that was expected. (Note: I do properly
populate the DataList with a valid DataSet and the results are correct
when the line above is omitted).

I have tried so hard to figure this out I am just hitting my head
against the wall. I have tried everything I can think of. I have a
book that tells me that it is possible to call a code-behind function
like this within a DataList (and my syntax above is almost exact). Any
advice or suggestions are greatly appreciated. Thank you for reading
this!

Best Regards,

Mike P

Apr 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2580
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i access the recordset it displays the results, what the real issue is that the entry is not made into the database even though i use the Update command and i have also tried the BeginTrans and CommitTrans nothign seems to work and i am unable to...
10
2032
by: Alejandro Castañaza | last post by:
Hi. I'm writing a program, and I need to send confidential data through the network, so I decided to use encryption, using the System.Security.Cryptography namespace. I'm using the sockets for the network communications, and the program first does a key exchange, with the asymetric cipher classes, to get a new key for the symmetric cipher. My problem is, that although I have checked that the two points get to the same key and...
7
2093
by: Andrew Christiansen | last post by:
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on a treeview control. I have the imagelist on the form filled with images, and have the ImageList property of the treeview control set to the imagelist containing the images I want to be displayed next to each node. It seems that no matter what I do there will be no images displayed next to the nodes during runtime. I tried creating nodes during designtime using...
8
7671
by: Flack | last post by:
Hey guys, In my app I have a bitmap where drawing is done and in the form's paint method I show the bitmap: private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if(MyBitmap != null) { Graphics g = e.Graphics;
5
3489
by: tkondal | last post by:
Hi all. I just started looking at Python's ctypes lib and I am having trouble using it for a function. For starters, here's my Python code: from ctypes import*; myStringDLL= cdll.LoadLibrary("myStringDLL.dll");
0
972
by: sachins5 | last post by:
Hi everyone, I am facing a problem here... my build was working fine till yesterday and then out of the blue every debug operation resulted in An unhandled exception of type occured in the following procedure: Main Error stack: Unexpected error starting ApplicationName(main) system.io.fileloadexception : Access is denied:'Data Access Layer', File name: "DataAccesslayer" at System.reflection.asembly.nload "DataAccesslayer" at...
2
2011
by: Stu | last post by:
Hi guys, I've been having trouble getting the clock function to work portably, please could I get some thoughts? <Possibly OT comments> It works fine on my laptop (under WinXP) and on my office computer (under Linux), but I have to write some code for the system simulator for the Cell BE processor (the thing inside the PS3), which is apparently a PPC architecture, and I can't get the clock function to
5
1430
by: polas | last post by:
Afternoon everyone. I am having some trouble and thought a few of you might be able to help me... I have a simple function to copy the contents of one array into another - the arguments to the function are the first array (to copy into), the second array (copy from) and the number of items to copy, the prototype is void cpyarray (float * a, float * b, int numbertocopy) - this worked fine initially. However, I would now like to use this...
0
2220
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): PERL5LIB=/Users/Ric/Library/Perl/ ls XML-Parser-2.34/ XML-Parser-2.34.tar
3
1201
by: Howard Swope | last post by:
Greetings: C++ CLR .Net 2 I have a ref class that I have created that wraps an unmanaged pointer. It acts like a smart pointer for reference counted objects for a particular library I am working in. I have overloaded the ->, *, assignment, and equality operators. I have created a ! finalizer and call it from my destructor. However, when I do so, the operator overload returns the type of the wrapped pointer.
0
7862
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8223
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6634
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5729
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1459
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1196
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.