473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How can call function using button?

The following lines of code calling TerminateManager.aspx page when I click on button(please see the code), instead of calling .aspx page I want to call function Check(), how can I do that?
This following code is written in aspx.cs page and the function Check() I like to call is also in the same page.

Expand|Select|Wrap|Line Numbers
  1. this.PlaceHolderTerminateManagerButton.Controls.Ad d(new LiteralControl("<input type='Button' value='Terminate Manager' onclick='javascript:location.href=\"TerminateManag er.aspx?orgID="+ orgID + "\";'"));
Mar 8 '10 #1

✓ answered by Bassem

Hey,

For the C# Method, use this:
1. The page that send the request:
Expand|Select|Wrap|Line Numbers
  1. this.PlaceHolderTerminateManagerButton.Controls.Ad d(new LiteralControl("<input type='Button' value='Terminate Manager' onclick='javascript:location.href=\"TerminateManag er.aspx?myParam=x";'")); 
2.The page that receive the request:
Expand|Select|Wrap|Line Numbers
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         string param = Request.QueryString["myParam"];
  4.         if("x" == param)
  5.             MyMethod();
  6.     }
  7.  
I hope that will help!

Thanks,
Bassem

4 3252
Bassem
344 100+
Function?
Is it a JavaScript function? or a C# Method?

The only way I know for both, is what you already did, sending a parameter:
Expand|Select|Wrap|Line Numbers
  1. ?orgID="+ orgID 
Then in your Page_Load Method, or onload function check these parameters and invoke the Method or call the Function.

Thanks,
Bassem
Mar 8 '10 #2
Bassem
344 100+
Hey,

For the C# Method, use this:
1. The page that send the request:
Expand|Select|Wrap|Line Numbers
  1. this.PlaceHolderTerminateManagerButton.Controls.Ad d(new LiteralControl("<input type='Button' value='Terminate Manager' onclick='javascript:location.href=\"TerminateManag er.aspx?myParam=x";'")); 
2.The page that receive the request:
Expand|Select|Wrap|Line Numbers
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         string param = Request.QueryString["myParam"];
  4.         if("x" == param)
  5.             MyMethod();
  6.     }
  7.  
I hope that will help!

Thanks,
Bassem
Mar 8 '10 #3
Thanks Baseem, I have created a simple button rather than using this java script and its working but I will try the way you have suggested. Thanks for your help!
Mar 9 '10 #4
Bassem
344 100+
Hi,

It wasn't a JavaScript code, it was a pure C# (Server-side code) - in case you will try it.

Thanks,
Bassem
Mar 11 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
5
by: Anand Ganesh | last post by:
Hi All, I need some help. I am sort of not sure how to approach this problem. I have a MAINPROGRAM. This is the core application. I have asked two of my staff to developed two different...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
1
by: prince -=nore=- | last post by:
I'm trying to open a new window when a button is clicked. I'm using the following code in my page_load to do so. Dim myScript As String = "<script language=javascript> function loadWin()...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
7
by: C.Joseph Drayton | last post by:
I have a problem that I am hoping someone can help me with. First let me describe the problem. I have an HTML form that in one field has an onBlur call to a JavaScript function. When you exit the...
3
by: msnews.microsoft.com | last post by:
Hi i am using User32.dll in Visual stdio 2005. public static extern long SetActiveWindow(long hwnd); public static extern long keybd_event(byte bVk, byte bScan, long dwFlags,
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
4
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.