C#后台怎么调用前台的JQ 类库c#js 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 调用还是执行?调用不可能,在生成的html中调用js函数应该是可以的。 主要就是实现我前台有一个HTML转换PDF的方法。我想在后台执行这个方法 可以在后台执行前台的js或jq语句,调用嘛你见过有后台间接执行js有返回值什么的吗。,。。好像他只是执行,之后都交给前台了 no way换思路可以js post,返回结果后再执行想调用的方法 。。以前用到的Js类。 /// <summary> /// 客户端脚本输出 /// </summary> public class JsHelper { /// <summary> /// 弹出信息,并跳转指定页面。 /// </summary> public static void AlertAndRedirect(string message, string toURL) { string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>"; HttpContext.Current.Response.Write(string.Format(js, message, toURL)); HttpContext.Current.Response.End(); } /// <summary> /// 弹出信息,并返回历史页面 /// </summary> public static void AlertAndGoHistory(string message, int value) { string js = @"<Script language='JavaScript'>alert('{0}');history.go({1});</Script>"; HttpContext.Current.Response.Write(string.Format(js, message, value)); HttpContext.Current.Response.End(); } /// <summary> /// 直接跳转到指定的页面 /// </summary> public static void Redirect(string toUrl) { string js = @"<script language=javascript>window.location.replace('{0}')</script>"; HttpContext.Current.Response.Write(string.Format(js, toUrl)); } /// <summary> /// 弹出信息 并指定到父窗口 /// </summary> public static void AlertAndParentUrl(string message, string toURL) { string js = "<script language=javascript>alert('{0}');window.top.location.replace('{1}')</script>"; HttpContext.Current.Response.Write(string.Format(js, message, toURL)); } /// <summary> /// 弹出信息 /// </summary> public static void Alert(string message) { string js = "<script language=javascript>alert('{0}');</script>"; HttpContext.Current.Response.Write(string.Format(js, message)); } } 主要就是实现我前台有一个HTML转换PDF的方法。我想在后台执行这个方法感觉浏览器环境中js还没有厉害到可以把html转pdf,估计是 C#的html转pdf,你可以把html传给后台~后台处理后在输出pdf web服务是无法主动发送消息到浏览器的。你可以把要生成PDF的数据传到后台去,然后生成PDF再响应回浏览器。 Empp的收发集成 Window服务问题? 关于在AJAX EXT1.0的webconfig文件中设置全局主题的问题 读取图片中的汉字 高分求正则表达式 如何学习vs2010开发系统 DataGrid列颜色(WinForm) 按钮文字显示不全 我用DirectShow时,在释放借口的时候,总是机器重启,为什么? 如何动态求表达式的值,就像JavaScript中的Eval函数。 设计个winform界面,输入数据,点击保存按钮,自动生成EXCEL表格保存 [求助]一个关于sqlDataAdpter.update更新主键的问题 往winform界面上拖一个第三方控件就报错
换思路
可以js post,返回结果后再执行想调用的方法
/// <summary>
/// 客户端脚本输出
/// </summary>
public class JsHelper
{
/// <summary>
/// 弹出信息,并跳转指定页面。
/// </summary>
public static void AlertAndRedirect(string message, string toURL)
{
string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
HttpContext.Current.Response.Write(string.Format(js, message, toURL));
HttpContext.Current.Response.End();
} /// <summary>
/// 弹出信息,并返回历史页面
/// </summary>
public static void AlertAndGoHistory(string message, int value)
{
string js = @"<Script language='JavaScript'>alert('{0}');history.go({1});</Script>";
HttpContext.Current.Response.Write(string.Format(js, message, value));
HttpContext.Current.Response.End();
} /// <summary>
/// 直接跳转到指定的页面
/// </summary>
public static void Redirect(string toUrl)
{
string js = @"<script language=javascript>window.location.replace('{0}')</script>";
HttpContext.Current.Response.Write(string.Format(js, toUrl));
} /// <summary>
/// 弹出信息 并指定到父窗口
/// </summary>
public static void AlertAndParentUrl(string message, string toURL)
{
string js = "<script language=javascript>alert('{0}');window.top.location.replace('{1}')</script>";
HttpContext.Current.Response.Write(string.Format(js, message, toURL));
} /// <summary>
/// 弹出信息
/// </summary>
public static void Alert(string message)
{
string js = "<script language=javascript>alert('{0}');</script>";
HttpContext.Current.Response.Write(string.Format(js, message));
} }
你可以把html传给后台~
后台处理后在输出pdf