?
Solved

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

Posted on 2003-11-28
3
Medium Priority
?
823 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
Question by:Yann de Champlain
[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 200 total points
ID: 9844248
it should be


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

Author Comment

by:Yann de Champlain
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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