?
Solved

Calling a function in different page from another page

Posted on 2016-10-05
6
Medium Priority
?
42 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
[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
  • 3
6 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 41830035
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
ID: 41830040
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 53

Expert Comment

by:Ryan Chong
ID: 41831077
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:mcrmg
ID: 41840193
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 53

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 41841381
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
ID: 41842628
thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

801 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