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 t开发者_JAVA百科o do so? If so, how?
<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;
}
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.
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.
<a href="?i=1" id ="a" runat = "server">
on Page_load()
if (Request.QueryString["i"] == "1")
{
//call ur code here
AreaFootPrint_Click(null,null);
}
if (orgvalid()) { insertorganisation(); } return false;
精彩评论