开发者

Inject method to codebehind from aspx page

I have an aspx page belonging to a legacy application. Since I cannot access to the relative aspx.cs file, I have to inject some needed logic through the aspx file, like:

<%
  using (myNamespace.myLinqContext cnt = new myNamespace.myLinqContext())
        {
         var warningText = (from c in cnt开发者_StackOverflow中文版.Table_Customer
                            where c.ID.Equals(CustomerId)
                            select c).First();
        }       
%> 

However I would get an exception since the namespace System.Linq is not imported in the codebehind file.

How could I import/use it in this context, so that I could execute the Linq query from the aspx page?


I don't know if it helps, but try to import Linq namespace directly in the aspx.

<%@ Import Namespace="System.Linq" %>

Also the page classes is partial, so maybe you can move your logic somewhere where you can ge access to the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜