Reputation: 35268
I use <a href="javascript:void(0);" onclick="orgvalid();return false;" class="regular">Register</a>
in my aspx page. Once true is returned from the function orgvalid()
I want to call a code behind function, insertorganization()
. Is it possible to do so? If so, how?
Upvotes: 2
Views: 26719
Reputation: 1924
<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;
}
Upvotes: 5
Reputation: 21
<a href="?i=1" id ="a" runat = "server">
on Page_load()
if (Request.QueryString["i"] == "1")
{
//call ur code here
AreaFootPrint_Click(null,null);
}
Upvotes: 1
Reputation: 1038850
You could use a LinkButton instead:
<asp:LinkButton id="RegisterButton"
Text="Register"
OnClientClick="return orgvalid();"
OnClick="Register_Click"
runat="server" />
and in the Register_Click server function you could call the insertorganization
method.
Upvotes: 3
Reputation: 25810
You should use a LinkButton instead
<asp:LinkButton ID="LinkButton1" CommandName="somecommandname"
runat="server" OnCommand="insertorganization"
CommandArgument="some praram">
Register
</asp:LinkButton>
To note that this will perform a postback.
Upvotes: 1