C#运用ajax实现updatepanel控件更新及弹窗
C#运用ajax实现updatepanel控件更新及弹窗
C#运用ajax实现updatepanel控件更新
一个页面要有不同的主题,如“我的主页”、“我的帖子”、“我的收藏”等等。 在点击相应功能时,如何实现页面的局部刷新呢? 有两种方法: 1、通过js调用.ashx页面,在.ashx中访问数据库、生成页面布局
C#运用ajax实现updatepanel控件更新及弹窗
C#运用ajax实现updatepanel控件更新
一个页面要有不同的主题,如“我的主页”、“我的帖子”、“我的收藏”等等。
在点击相应功能时,如何实现页面的局部刷新呢?
有两种方法:
1、通过js调用.ashx页面,在.ashx中访问数据库、生成页面布局,将生成的局部页面返还给.aspx页面。
2、运用updatepanel控件。
updatepanel
在各类网站上用的较多的教程是updatepanel控件的运用,先来一波模板代码:
//这个一定要有,且若页面中有多个updatepanel控件,要将EnablePartialRendering属性设置为true
<asp:ScriptManager ID=ScriptManager1 runat=server></asp:ScriptManager>
<asp:UpdatePanel ID=ickameUpdate runat=server>//contenttemplate中放置内容或其它控件<ContentTemplate><a href=../login_logister/usr_login.aspx>用户登陆</a> <a href=../login_logister/usr_logister.aspx>这里注册</a></ContentTemplate>//触发器,一定要有<Triggers><asp:AsyncPostBackTrigger ControlID=触发器ID Eventame=avigate /></Triggers>
</asp:UpdatePanel>
triggers有的两种触发器asyncpostbacktrigger和postbacktrigger。
asyncpostbacktrigger(异步回调触发器):局部刷新,只刷新updatepanel内部的内容
postbacktrigger(普通回调触发器):全部刷新
<asp:UpdatePanel ID=UpdatePanel1 runat=server><ContentTemplate><% =ToString()%></ContentTemplate><Triggers><asp:PostBackTrigger ControlID=btn /><asp:AsyncPostBackTrigger ControlID=btn2 Eventame=click /></Triggers></asp:UpdatePanel><asp:Button runat=server Text=刷新1 id=btn/><asp:Button runat=server Text=刷新2 id=btn2 /><% =ToString()%>
在updatepanel中的控件因为刷新,所以可能使用js的弹窗会有障碍,那么这个语句就可以成功解决啦!
ScriptManager.RegisterStartupScript(this.UpdatePanel1,this.GetType(), 提示, alert( 购物车为空,请先购物! ), true);
ashx局部刷新
在h5页面代码 中
<head >
<script type=text/javascript>/*** *运行ashx,type是传递的参数* @param type*/function themeSearch(type) {var type1=type;go(ThemeManage.ashx?type= type);}/*** *跳转功能执行,destination指的是跳转地址,运行完毕在.ashx中返回h5语句* @param destination*/function go(destination) {(get, destination);http.send(); = callback;}function callback(){if (http.readyState == 4 && http.status == 200) {document.getElementById(RightColumn).innerHTML = http.respeText;}}</script >
< /head>
在body中,随便一个链接控件,button或者hyperlink或者a都可以,传递的参数固定可以直接输入,如果是变量那么那么就用document.getElementById(“控件id”)获取控件,加上.value获取控件值。在script中声明任何变量都是用var
<body><asp:HyperLink ID=ThemeManage runat=server onclick=themeSearch( 主题管理 ) Text=主题管理 />
</body>
然后在ashx中随意编辑什么就可以在页面中得到了
#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
上传时间: 2024-01-10 11:50:57
下一篇:格式工厂 wav 比特率
推荐阅读
留言与评论(共有 18 条评论) |
本站网友 可望 | 15分钟前 发表 |
通过js调用.ashx页面,在.ashx中访问数据库 | |
本站网友 南鹏岛 | 12分钟前 发表 |
updatepanel 在各类网站上用的较多的教程是updatepanel控件的运用,先来一波模板代码: //这个一定要有,且若页面中有多个updatepanel控件,要将EnablePartialRendering属性设置为true <asp | |
本站网友 车祸网 | 11分钟前 发表 |
destination);http.send(); = callback;}function callback(){if (http.readyState == 4 && http.status == 200) {document.getElementById(RightColumn).innerHTML = http.respeText;}}</script > < /head> 在body中,随便一个链接控件,button或者hyperlink或者a都可以,传递的参数固定可以直接输入,如果是变量那么那么就用document.getElementById(“控件id”)获取控件,加上.value获取控件值 | |
本站网友 夜色ktv | 5分钟前 发表 |
UpdatePanel ID=ickameUpdate runat=server>//contenttemplate中放置内容或其它控件<ContentTemplate><a href=../login_logister/usr_login.aspx>用户登陆</a> <a href=../login_logister/usr_logister.aspx>这里注册</a></ContentTemplate>//触发器,一定要有<Triggers><asp | |
本站网友 乙酰螺旋霉素 | 16分钟前 发表 |
HyperLink ID=ThemeManage runat=server onclick=themeSearch( 主题管理 ) Text=主题管理 /> </body> 然后在ashx中随意编辑什么就可以在页面中得到了 | |
本站网友 金丽华酒店 | 20分钟前 发表 |
生成页面布局,将生成的局部页面返还给.aspx页面 | |
本站网友 跳水猪 | 27分钟前 发表 |
在点击相应功能时,如何实现页面的局部刷新呢? 有两种方法: 1 | |
本站网友 脑蛋白水解物 | 22分钟前 发表 |
true); ashx局部刷新 在h5页面代码 中 <head > <script type=text/javascript>/*** *运行ashx,type是传递的参数* @param type*/function themeSearch(type) {var type1=type;go(ThemeManage.ashx?type= type);}/*** *跳转功能执行 | |
本站网友 上海房屋出租信息 | 23分钟前 发表 |
UpdatePanel><asp | |
本站网友 纯粹网 | 20分钟前 发表 |
C#运用ajax实现updatepanel控件更新及弹窗 C#运用ajax实现updatepanel控件更新 一个页面要有不同的主题,如“我的主页” | |
本站网友 黑脸娃娃怎么做 | 21分钟前 发表 |
updatepanel 在各类网站上用的较多的教程是updatepanel控件的运用,先来一波模板代码: //这个一定要有,且若页面中有多个updatepanel控件,要将EnablePartialRendering属性设置为true <asp | |
本站网友 红豆薏米 | 4分钟前 发表 |
alert( 购物车为空 | |
本站网友 人口普查网 | 8分钟前 发表 |
UpdatePanel ID=ickameUpdate runat=server>//contenttemplate中放置内容或其它控件<ContentTemplate><a href=../login_logister/usr_login.aspx>用户登陆</a> <a href=../login_logister/usr_logister.aspx>这里注册</a></ContentTemplate>//触发器,一定要有<Triggers><asp | |
本站网友 衡阳楼市 | 7分钟前 发表 |
HyperLink ID=ThemeManage runat=server onclick=themeSearch( 主题管理 ) Text=主题管理 /> </body> 然后在ashx中随意编辑什么就可以在页面中得到了 | |
本站网友 营口白沙湾 | 30分钟前 发表 |
“我的帖子” | |
本站网友 万达电影院 | 16分钟前 发表 |
true); ashx局部刷新 在h5页面代码 中 <head > <script type=text/javascript>/*** *运行ashx,type是传递的参数* @param type*/function themeSearch(type) {var type1=type;go(ThemeManage.ashx?type= type);}/*** *跳转功能执行 | |
本站网友 麻疹症状 | 10分钟前 发表 |
通过js调用.ashx页面,在.ashx中访问数据库 |