Solved

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

Posted on 2003-11-28
3
811 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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