Click here to Skip to main content
16,012,352 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How can I get the Controls ID in different page?
Posted
Updated 26-Oct-10 0:24am
v2
Comments
Ankur\m/ 26-Oct-10 6:57am    
I have added a comment against your reply. Please check.

Controls are page specific. If you want to expose a certain control values to other page then you can expose them using properties (get-set) .

Further, if you have page instance then you can use 'FindControl' method of the page to find a control of that page using control ID.

UPDATE:
You modified your question a little. Please don't delete once answered.
If you are looking to pass on the ID of control to various pages then you can use query string or sessions for the same.

Is these does not help, then it would be better to share the scenario you are working on.


UPDATE 2:
See, how answer can change as soon you tell your scenario. You simply need to design a User Control. Have the parameter controls in this user control and then use this user control on all the pages where you need.
 
Share this answer
 
v3
Comments
Arun K V 26-Oct-10 6:27am    
I have a panel in one page(report.aspx).I have to get this panel in another page New Report.aspx.cs
Arun K V 26-Oct-10 6:27am    
Is this possible??
Sandeep Mewara 26-Oct-10 6:33am    
Answer updated!
Arun K V 26-Oct-10 6:33am    
I am trying to get the value of the panel control. I tried this Panel editReference = (Panel)PreviousPage .FindControl("pnlEditReference"); But the error occurs that object reference is not set to an instance
Sandeep Mewara 26-Oct-10 6:35am    
Have a look at these links"
http://msdn.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspx
http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx
I edited and answered this question. But can't find it anymore in your question list. Have you deleted it?

How can I get the Controls ID in different page??

You cannot get the control id of a page in another page.
But there are ways you can get the value of a control.

Can you explain what you are trying to do?
 
Share this answer
 
Comments
Arun K V 26-Oct-10 6:32am    
I am trying to get the value of the panel control.
I tried this
Panel editReference = (Panel)PreviousPage .FindControl("pnlEditReference");
But the error occurs that object reference is not set to an instance
Ankur\m/ 26-Oct-10 6:56am    
It means that the PreviousPage property is not initialized.
Are you doing a cross page posting?
Read this MSDN article for more detail: http://msdn.microsoft.com/en-us/library/ms178139.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900