Solved

A c# function return undefined (ASP.NET C#)

Posted on 2003-11-28
3
798 Views
Last Modified: 2010-08-05
Hello,
This one should be easy...

Still learning C# I am stuck with that...

I have a function getQuote(string SYMB) in my aspx.cs file at this point for debugging, getWuote return SYMB:

Her is the cs file:

---------------------

namespace StockQuote
{
      /// <summary>
      /// Summary description for WebForm1.
      /// </summary>
      public class WebForm1 : System.Web.UI.Page
      {

            private void Page_Load(object sender, System.EventArgs e)
            {
                  // Put user code to initialize the page here



            }
            
      
            #region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
            {
                  //
                  // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                  //
                  InitializeComponent();
                  base.OnInit(e);
            }
            
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {    
                  this.Load += new System.EventHandler(this.Page_Load);

            }
            #endregion
      
            public string getQuote(string SYMB)
         {
                  return SYMB;
            }
      }
}
---------------------
Here is part of the form aspx:
I want a funsction to return a string in my javascript section.  It currently return "undefined"
What going on?

...
<script language="JavaScript">
...
myScroller1.addItem(<%getQuote("molb.to");%>);
...
      </script>
      </form>
0
Comment
3 Comments
 
LVL 1

Expert Comment

by:AJMartin
ID: 9840100
I think that this line:

 myScroller1.addItem(<%getQuote("molb.to");%>);

should be like:

 myScroller1.addItem(<%WebForm1.getQuote("molb.to");%>);

I hope that helps!
0
 
LVL 18

Accepted Solution

by:
testn earned 50 total points
ID: 9844248
it should be


myScroller1.addItem(<%=getQuote("molb.to")%>);
0
 

Author Comment

by:Yann de Champlain, PMP
ID: 9850414
WebForm1.getQuote("molb.to"); is not working. but myScroller1.addItem(<%=getQuote("molb.to")%>); is!.

I tried (<%=getQuote("molb.to")%> but with a ";" after the method.  I don't know why we don't need a ; after the line.

Thanks a lot for your answer!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question