How can call function using button?

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Bassem
    replied
    Hi,

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

    Thanks,
    Bassem

    Leave a comment:


  • Deven Oza
    replied
    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:


  • Bassem
    replied
    Hey,

    For the C# Method, use this:
    1. The page that send 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";'"));
    2.The page that receive the request:
    Code:
        protected void Page_Load(object sender, EventArgs e)
        {
            string param = Request.QueryString["myParam"];
            if("x" == param)
                MyMethod();
        }
    I hope that will help!

    Thanks,
    Bassem

    Leave a comment:


  • Bassem
    replied
    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:
    Code:
    ?orgID="+ orgID
    Then in your Page_Load Method, or onload function check these parameters and invoke the Method or call the Function.

    Thanks,
    Bassem

    Leave a comment:


  • Deven Oza
    started a topic How can call function using button?

    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 + "\";'"));
Working...