如何在没有javascript回发的情况下调用函数后面的代码? [英] How can i call a code behind function without postback in javascript?

查看:77
本文介绍了如何在没有javascript回发的情况下调用函数后面的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在页面中调用函数而不使用ajax回发。此调用应在关闭弹出窗口后完成。在该窗口中我向会话添加一些记录,在父页面中我应该在datagridview中显示这些记录。我怎么能这样做?

这是用于打开弹出窗口的js代码。

I want to call a function in page without postback with ajax.This call should be done after closing a popup window. in that window i add some record to a session and in parent page i should show those record in a datagridview. how can i do that?
this is js code for opening popup window.

function ShowDialog() {
var ret = window.showModalDialog("ReceiverPage.aspx", "MyWindow", "dialogWidth:1000px; dialogHeight:600px; resizable:no; ");
        ret = true;
        if (ret) {
            javascript:__doPostBack('<%= Button1.ClientID %>', 'onclick');            
            return true;
        }
    }







谢谢高级。




Thanks in advanced.

推荐答案

编写一个javascript函数,当你关闭弹出窗口时将调用该函数,并在该函数中使用jquery调用web方法。写你的逻辑(给会话增加一些价值)......



希望这会有所帮助。
Write a javascript function which will be called when you closes the popup and in that function call a webmethod using jquery. write your logic(add some value to session)...

hope this helps.


你可以使用AJAX来执行回调服务器端C#代码,如果你想避免回发,这通常是在你希望给用户一个流畅的应用程序而不是基于页面的行为的稳定感觉时完成的。



请参阅教程:在AJAX中使用jQuery ASP.NET [ ^ ]



干杯,

Edo
You can use AJAX to perform calls back to the server side C# code, if you want to avoid the Postback, this is commonly done when you wish to give the user the steady feeling of a flowing application rather than a page based behavior.

See tutorial: Using jQuery for AJAX in ASP.NET[^]

Cheers,
Edo


尝试使用这个解决方案。

在没有PostBack的情况下调用代码隐藏功能 [ ^ ]
Try to use this solution.
Calling Code Behind function without PostBack[^]


这篇关于如何在没有javascript回发的情况下调用函数后面的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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