Hi all.
Just caught up in the mess when I came to see : the parent page of one of my class library control was null at runtime. That means the call:
Page.ClientScript.GetWebResourceUrl([control-type],[full-resource-url]);
would fail.
I have been suggested this happens when my parent page is being rendered within an iframe. But this was not the case for now. I was just using a placeholder to dynamically add the control. So what's the solution?
Yes it came around after some googling, try this:
(Page)HttpContext.Current.Handler).ClientScript.GetWebResourceUrl([control-type],[full-resource-url]);
What's in here?
The Page that refers to the Page control containing this dynamic control is achieved through current request handler. This avoids the problem since the request was generated by the page. But mere Page or this.Page or this.Parent.Page or whatsoever might have been missed due to the hierarchy of the controls or is it due to anything else?
Hope this helps. Sweet programming!
Saturday, June 18, 2011
Page is null at the c# class library control
Labels:
ASP.NET,
ASP.NET Control
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Most of the times programmers fill the DataTable from database. This action fills the schema of the database table into the DataTable . We ...
-
I have found much tricks in different tutorials and forums on opening new window in asp.net web page, using JavaScript, jquery etc. Here I h...
-
The asp.net Eval() and Bind() expressions are heavily used in asp.net GridView and DetailsView data bound controls. The difference between ...
-
I have oracle database installed in my computer. My Operating system is XP. I wrote an application in asp.net. It connected to oracle databa...
-
Last time I got the following error: HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related ...
-
Last time we talked about Refreshing the parent page from child window in asp.net using javascript . This technique is useful in many scenar...
-
We do have a folder (and a number of sub folders) with a number of various files in those folders (and sub folders). Now we do need to list ...
-
In this post, I am explaining the button click functionality on key press in a textbox. I am using javascript to link the input textbox and ...
-
Much often we open child windows from parent web page . In the child page we perform some activities, and later close the window. At the ver...
-
The default behaviour of asp.net gridview is that it hides both Gridview header and footer when no data is present. You can note the absence...
0 comments:
Post a Comment
Hope you liked this post. You can leave your message or you can put your valuable suggestions on this post here. Thanks for the sharing and cooperation!