Hi,
It wasn't a JavaScript code, it was a pure C# (Server-side code) - in case you will try it.
Thanks,
Bassem
How can call function using button?
Collapse
X
-
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!Leave a comment:
-
Hey,
For the C# Method, use this:
1. The page that send the request:
2.The page that receive the request:Code:this.PlaceHolderTerminateManagerButton.Controls.Ad d(new LiteralControl("<input type='Button' value='Terminate Manager' onclick='javascript:location.href=\"TerminateManag er.aspx?myParam=x";'"));
I hope that will help!Code:protected void Page_Load(object sender, EventArgs e) { string param = Request.QueryString["myParam"]; if("x" == param) MyMethod(); }
Thanks,
BassemLeave a comment:
-
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:
Then in your Page_Load Method, or onload function check these parameters and invoke the Method or call the Function.Code:?orgID="+ orgID
Thanks,
BassemLeave a comment:
-
How can call function using button?
The following lines of code calling TerminateManage r.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.
Code:this.PlaceHolderTerminateManagerButton.Controls.Ad d(new LiteralControl("<input type='Button' value='Terminate Manager' onclick='javascript:location.href=\"TerminateManag er.aspx?orgID="+ orgID + "\";'"));Tags: None
Leave a comment: