如何在C#asp.net中从ASPX页面到ASHX页面访问ASP服务器控件 [英] How to access asp server controls from aspx page to ashx page in c# asp.net

查看:172
本文介绍了如何在C#asp.net中从ASPX页面到ASHX页面访问ASP服务器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我已经在c#asp.net中使用* .ashx(通用处理程序文件).现在,我想通过.ashx(通用处理程序文件)文件绑定网格视图.现在,例如.通常我们在C#代码后面的代码中绑定网格视图,就像我想通过处理程序ashx文件进行网格视图绑定一样.为此,我该如何实现.

例如.在aspx页面

Hi Friends,

I have used *.ashx (generic handler file) in c# asp.net. Now I want to bind grid view though .ashx (generic handler file)file. Now Eg. Normally we are binding grid view in code behind C# code like that I want do grid view binding though handler ashx file. To do this how I can achieve this.

Eg. In aspx page

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"

AllowPaging="true" DataKeyNames="AutoId"

PageSize="5" PagerSettings-Mode="Numeric">
<columns>
<asp:TemplateField HeaderText="Select">
<itemtemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</itemtemplate>

<asp:BoundField HeaderText="Last Name" DataField="LastName" />
<asp:TemplateField HeaderText="Is Active?">
<itemtemplate>
<%# Eval("Active").ToString().Equals("True") ? "Yes" : "No" %>
</itemtemplate>
</columns>


C#* .cs文件后面的代码.


Code behind C# *.cs file.

this.GridView1.DataSourceID = this.SDSForMainGrid.ID;
this.GridView1.DataBind();

//Normally we binding in c# .cs code  
// similarly in *.ashx file

this.GridView1.DataSourceID = this.SDSForMainGrid.ID;
this.GridView1.DataBind();



谢谢
PBN



Thanks
PBN

推荐答案

.ashx和.aspx请求的HTTP处理程序是不同的.这些是基于扩展的处理程序,根据扩展将请求转移到特定的处理程序,并且处理方式有所不同.您可以同时使用它们,但不能混合使用.

http://stackoverflow.com/questions/391130/what-is-a- httphandler-in-asp-net [ ^ ]
The HTTPhandlers for .ashx and .aspx requests are different. These are extension based handlers and the requests are diverted to a particular handler depending upon the extension and are processes differently. You can use both of them but cannot mix them.

http://stackoverflow.com/questions/391130/what-is-a-httphandler-in-asp-net[^]


这篇关于如何在C#asp.net中从ASPX页面到ASHX页面访问ASP服务器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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