Solved

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

Posted on 2003-11-28
3
795 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
Comment Utility
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
Comment Utility
it should be


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

Author Comment

by:Yann de Champlain, PMP
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now