Solved

Calling a function in different page from another page

Posted on 2016-10-05
6
32 Views
Last Modified: 2016-10-13
Hi,

I understand that a class needs to be created in order to do this.  But what if there is nothing to return? Say, I just want to have a msg box popup?

thanks
0
Comment
Question by:mcrmg
  • 3
  • 3
6 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
But what if there is nothing to return? Say, I just want to have a msg box popup?
In general, you can do "whatever" you want in the class, you can call a method in a class to do a message pop up, or return some objects, or variables if you want to,or you can even call a method of a class to accomplish something but without return anything.

all depends on what you want to do with your self-defined class.
0
 

Author Comment

by:mcrmg
Comment Utility
I am testing a method. But I am getting error

CS1520: Method must have a return type

public class test
{
	public test1()
	{
        protected void test_Click(object sender, EventArgs e)
        {

             System.Windows.Forms.MessageBox.Show("HERE");



        }
	}
}

Open in new window

0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
are you trying to do this in asp.net? if yes, try this:

web front:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="test" %>
...
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

Open in new window

code behind:
public partial class test : System.Web.UI.Page
    {
        protected void Button1_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('HERE')", true);
        }
    }

Open in new window


MessageBox is used for window applications
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:mcrmg
Comment Utility
Sorry for the late reply.

It works.  thank you.

What if there are a few function I would like to share across the board?  Is there a way to do it?  thanks
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 500 total points
Comment Utility
What if there are a few function I would like to share across the board?  Is there a way to do it?
yes, you can similarly. but you probably need to defined shared (static) classes then.

as a start, you can refer to:

Static Classes and Static Class Members (C# Programming Guide)
https://msdn.microsoft.com/en-us/library/79b3xss3.aspx
0
 

Author Closing Comment

by:mcrmg
Comment Utility
thank you
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

11 Experts available now in Live!

Get 1:1 Help Now