Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get parent page name in the user control page using C#

Tags:

html

c#

asp.net

i have about 10 pages using the same User Control,now i need to know each time what Page invoked the user control.and i need the page name(title).

like image 617
MaxPetya Avatar asked Jul 26 '13 21:07

MaxPetya


People also ask

How do you call the parent page method in user control?

Use event and delegate concept make delegate as same signature as your method in parent page and then assign parent methad to it in parent page load event then call this delegate through event in user control. code sample and link is given below. Show activity on this post.

How do you access the hidden field of the parent page in the user control?

Answers. In your user control code behind (C#) you can use... HiddenField hf = (HiddenField)Parent.


2 Answers

Try using within the control code:

this.Page.Title
like image 83
Yuriy Galanter Avatar answered Oct 26 '22 23:10

Yuriy Galanter


This is using javascript ,

<script language="javascript">
var parentName= "<%= System.IO.Path.GetFileName(Page.Request.Path) %>";    
</script>

or

this.Parent.Page.Title;
like image 35
zey Avatar answered Oct 26 '22 22:10

zey