.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Page in another page as an object

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net

Hi All,

I am trying to check if a control exist on another page, so i have:

page1.aspx and page2.aspx

In page1.aspx, i need to check if page2 has an control with id "textboxFindMe", how can i do that?
Also notice that page2 is dynamically build, so control "textboxFindMe" only exist in a condition, like certain time of the day.

Ideally, i would like to return an object on page2.aspx and use it in page1.aspx. I assumed page2 need to render first, otherwise the control would not be exist to be found in page1.aspx

code will be something like:

Page2 _page2 = new Page2();
Control ctrl = _page2.FindControl("textboxFindMe");

Any ideas?
Many Thanks.

View Complete Post

More Related Resource Links

Send object from one page to another



I want to create object in 1.aspx, and then send it to 2.aspx. This methods are bad, because:

1)Send object with url, like this:


This is not confidential.


Session["field1"] = "12345"; // set
Object foo = Session["field1"]; // get

This is bad too, because in 2.aspx this fields send to textboxes, and if user go to 2.aspx without 1.aspx, he'll see old data. 

send data in class object from one page to another using session


hello everybody

now i hav stored all data like user name, data fatched from database of that user

and i stored that data and user name such as:

string strUserName="user name"

dataset ds =new dataset();// data of that user

now i wan yo send d whole data from my login page to user profile page

can anybody help me for that...................

and plz tell me that how much is this way is benifitial to send data from one page to another page

plz........kindly waiting for positive rply

public object on asp,net page


in asp.net can i make public objects on my page, for example

public Customer cust1 = new customer();

and use this object on my entire code???

what are the drawbacks of creating public objects??

a single object will be created for all users??? or each user will have a different object????

Using extensions with Object Class and Page in WPF

I don't usually ask a question without trying it first, but hey, why not.  Searching for this one is not exactly easy. I am wondering if I can use extensions with Object and if they (the variables) will subsequently be available for use in a Page partial class generated for WPF?  By this I mean in the same project and assembly. BTW, I won't be offended by posts pointing out why not to do this with Object.  The why in this case is something as basic as having one base class that contain: bYes = True; bNo = False; Now of course, having a base class is not going to work with something like Page... There may be much better ways to this, what I do not want is syntax MyBaseInstance.bYes and MyBaseInstance.bNo in MyPageInstance and bYes or bNo everywhere else.  Any advice? Regards,  Dave Horsman

The SQL Server performance counter 'Page Splits/sec' (instance 'N/A') of object 'SQLServer:Acce

I am getting these page split errors every 5 minutes I have tried everything reindexing rebuilding working with different fill factor values But nothing seems to effect this problem. The threshold is now set to 100 (what the max threshold number i can set the alert to ?) Also please let me know how to get rid of the pagesplit alerts. thanks

Transfer values from one page to another Request Object



I wanTransfer values from one page to another using Request Object

but when i try store

textBox value into Request object like..

Request["Name"] = txtName.Text;

i get the following Error

Property or indexer 'System.Web.HttpRequest.this[string]' cannot be assigned to -- it is read only

Is Request object allows us to store values init like Session & Application Object............

Transfer values from one page to another Request Object



I want to Transfer values from one page to another using Request Object

but when i try store

textBox value into Request object like..

Request["Name"] = txtName.Text;

i get the following Error

Property or indexer 'System.Web.HttpRequest.this[string]' cannot be assigned to -- it is read only

Is Request object allows us to store values init like Session & Application Object............
Taha Zubair Ahmed Software Emgineer.

page inside update panel doesn't refresh the session object after postback of any control



I have many controls like dropdown, radiobuttonlist, etc on my page and I put all these controls inside the update panel so that the page doesn't look to be posting back when something is selected. Now the working on the page is very smooth. But the session object isn't getting refreshed even if I postback to the server and as a result even if the users are working on the page they are being sent to the login screen after 20 mins.

Is there anyway where I could put all the controls in update panel and still refresh the session after any postback(dropdown selection)

Any help is greatly appreciated.

Thanks in advance

how to persist a class object when page PostBack


i have created a user control UserControl.ascx, in Code behind file of UserControl.ascx i have created an object of a class MyClass.cs,
if(!Page.IsPostback) {
objMyClass= new MyClass();
but when i click on button of UserControl.ascx page and try to access objMyClass object then it set as null, so how to persist MyClass object when page PostBack, i wanted to keep object persist till the user access the page, when user goes out of this page then object should distroy?

To keep the object persist, i have used ViewState

So i have made MyClass Serializable and
i have used ViewState to keep my objet persist, but it give the error
like : UserControl is not marked as serializable.

so i have made my UserControl as Serializable, but the problem is still coming.

One more thing is that MyClass is also resposnsible to create some other class object also.

Can any one suggest me correct solution?

Problem i am getting when i try to PersisObject On UserControl

[SerializationException: Type 'ASP.common_grid_UserControl_ascx' in Assembly 'App_Web_44142fbl, Version=, Culture=neutral, PublicKeyToken=null' is not marked as serializable.] System.Runtime.Serialization.FormatterServices.InternalGetSeri

Accessing object in Razor Page


 hi, now if i want to iterate through the object it doesnt seems to work :

var myobject = new{param1 = "value1" , param2 = "value2" }

foreach(var i in myobject){




doesnt work , any ideas ?

thank you

Getting Object required, but page function still works..


Want to clear the yellow exclamation point in the browser.. it builds fine, it works fine, but if you happen to look down in the bottom or your browser is setup to display these errors, you will get  an error message that reads

Object Required
Code: 0
Line: 13

When i view the source of the page here is what i have for those lines, then below that is how its written in the aspx page, what did i miss or do wrong?


<script type="text/javascript">
        function showsearchMenu(num) {
            for (var i = 0; i <= 4; i = i + 1) {
                if (i != num)
                    document.getElementById('searchNav' + i).style.display = "none";  --------------->>> This is line 13
                    document.getElementById('searchNav' + i).style.display = "block";
        function goSearchOption(theoption) {
            for (var i = 1; i <= 3; i = i + 1) {
                if (i != theoption)
                    document.getElementById('searchOption' + i).style.display = "none";
                    document.getElementById('searchOption' + i).style.display = "block";

ASP.NET Compile / Initialise System.Web.UI.Page into memory object



I wonder if anybody could help me out with compiling and initialising an ASP.NET page into memory. I want to be able to create an instance of the page using something along the lines of:

Dim o As TestPage = New TestPage ' TestPage is just your avereage ASPX page.

I know at this stage I can use reflection to iterate the classes properties and return their values. However if I call o.Controls.count this is always 0. I guess this is because the page hasn't been through it's initialisation steps that it would usually go through if requested by a client. Can anybody help me initialise the page properly so that the o.Controls property is populated and I'm able to access the control tree in the same way you could do so in say the Page_Load method.



Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Reduce ASP.NET Page size and complexity using JQuery

This is my first post on asp.net blog. ASP.NET Ajax and JQuery are two different ajax framework. In this post I will show, how we can enhance gridview using ASP.NET Ajax and JQuery. I also compare the implementation of these frameworks. In next posts i will explain more about JQuery and ASP.NET Ajax and also tell you "How to combine the power of both framework". My Future post will related to ASP.NET and related frameworks.


I have 2 web pages. First page has a textbox and a button control.

when I enter test and click on the button , system goes to the second page. And in the second page I want to access the Textbox in the first page. When I try to do this I get the following error.

"Object reference not set to an instance of an object. Following is my code :

Dim txt As New TextBox

' Find the server name on the previous page
txt = CType(Page.PreviousPage.FindControl("TextBox2"), TextBox)
If Not IsNothing(txt) Then
Response.Write("[Name Not available]")
End If

I know I could do this with session, but I want to use the Page.PreviousPage.FindControl. Any help is greatly appreciated

Unique content within master page based on conditions met


 Hi all-

I would like to present users with unique content based on certain conditions being met as they land on the home page (default.aspx).  The condition logic will be in the VB code behind Page Load event. The content will go in a content placeholder as specificed from the master page. 

However, the content change wouldn't be something small (ie making a panel or label visible or not) but rather it will be different HTML,  Divs and databound gridview content.  The HTML content will be stored in the database.

Can someone point me in the right direction for best practices on how to accomplish this?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend