Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  39] [ 5]  / answers: 1 / hits: 30047  / 10 Years ago, tue, march 18, 2014, 12:00:00

I have a server side function



protected void SearchButton_Click(object sender, EventArgs e)       
{

}


I need to call the same from a client side script



function calSearch()
{
// here I need to call the client side script
}

More From » asp.net

 Answers
17

You cant do this, your option is to simulate Click of a button using javascript.



<asp:Button ID=savebtn runat=server OnClick=savebtn_Click style=display:none />


HTML markup will look like this:



<button id=btnsave onclick=fncsave()>Save</button>


now simulate a Click using JS



<script type=text/javascript>
function fncsave()
{
document.getElementById('<%= savebtn.ClientID %>').click();
}
</script>


Other solution would be to use ajax.


[#71932] Sunday, March 16, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
emiliano

Total Points: 381
Total Questions: 109
Total Answers: 93

Location: Jersey
Member since Fri, Oct 1, 2021
3 Years ago
emiliano questions
;