从Javascript调用服务器端方法 [英] Call Server Side method from Javascript

查看:85
本文介绍了从Javascript调用服务器端方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何从JavaScript调用服务器端方法而不使用Ajax



How to call Server side method from JavaScript without using Ajax

推荐答案

christokavi

例如,您有一个不包含任何记录(例如员工详细信息)的网格视图,那么您有一个按钮VIEW用于在另一个面板控件上显示选定的员工详细信息.现在我需要一个功能,当您双击该行然后显示与查看"按钮相同的详细信息.

请参考,
网格视图行导航
Hi christokavi,

For example you have grid view containing no of records(ex. Employee details), then you have a button VIEW for displaying selected employee details on another panel controls. Now i need a feature that when you double click the row then display the details same as the VIEW button.

Please refer,
Grid View Row Navigation done by Mr.Samir NIGAM Thank you Samir:thumbsup::thumbsup:

I have taken the above article for my example and then i added the feature for double click which your requirement.

Controls
Gridview - gvData
VIEW button - btnView

public void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
{
    e.Row.Attributes.Add("ondblclick", "javascript: document.getElementById(''ctl00_ContentPlaceHolder1_btnView'').click(); return false;");
}



根据代码,我刚刚通过gvData事件中的javascript调用了服务器端方法btnView事件.

如果您有任何疑问,请告诉我.

问候,
thatraja



According to the code i just called the server side method btnView event by javascript in gvData event.

If you have any doubt then let me know.

Regards,
thatraja


AJAX用于通过javascript调用服务器.

除此之外,您可以将表单发布到服务器.只需执行Form.Submit()

您可以为此使用IPostBackEventHandler.实际上,您放置在ASP.NET中的每个按钮,实际上都是通过Form.Submit()通过javascript发布的.只需检查页面的查看"->源"即可.

:rose:
AJAX is used to call a server through javascript.

Other than that, you can post a form to the server. Just do Form.Submit()

You can use IPostBackEventHandler for that. Actually every button you place in ASP.NET, the page is actually posted using Form.Submit() through javascript. Just inspect the View->Source of the page.

:rose:


这篇关于从Javascript调用服务器端方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆