R...">

Onclick anchor tag for calling code behind method

I am using <a href="javascript:void(0);" onclick="orgvalid();return false;" class="regular">Register</a>

aspx in my page. As soon as the function returns true orgvalid()

, I want to call the code behind function insertorganization()

. Can this be done? If so, how?

+2


source to share


5 answers


<a href="#" onclick="insertOrganization();return false;" class="regular">Register</a>

      

InserOrganization function:



function InsertOrganization(){
  if(orgvalid()){
     //do your thing here
  }
  else
    alert("not valid");
}

function orgvalid(){
  if({condition for true})
    return true;
  else
    return false;
}

      

+5


source


LinkButton can be used instead :

  <asp:LinkButton id="RegisterButton"
   Text="Register"
   OnClientClick="return orgvalid();"
   OnClick="Register_Click"
   runat="server" />

      



and in the server function Register_Click you can call the method insertorganization

.

+3


source


You should use LinkButton instead

    <asp:LinkButton ID="LinkButton1" CommandName="somecommandname" 
runat="server" OnCommand="insertorganization" 
CommandArgument="some praram">
Register
</asp:LinkButton>

      

Note that this will do postback.

+1


source


<a href="?i=1" id ="a" runat = "server">

on Page_load()
if (Request.QueryString["i"] == "1")
{
//call ur code here
AreaFootPrint_Click(null,null);
}

      

+1


source


if (orgvalid()) { insertorganisation(); } return false;

      

0


source







All Articles