<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Getting Started</title><link>http://forums.asp.net/15.aspx</link><description>The perfect forum for ASP.NET novices. No question too simple! &lt;A href="http://aspadvice.com/SignUp/list.aspx?l=21&amp;amp;c=17" target=_blank&gt;Email List&lt;/A&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/3249841.aspx</link><pubDate>Mon, 22 Jun 2009 07:12:09 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3249841</guid><dc:creator>DEMO</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3249841.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=3249841</wfw:commentRss><description>&lt;span style="FONT-SIZE:12pt;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;Hello all.&lt;/span&gt;&lt;span style="FONT-SIZE:12pt;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;I&amp;nbsp;have a problem when i try to compile i get an error which says that i didn’t t inherits user control .&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;COLOR:black;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;Abstract class i inherits&amp;nbsp; as you wrote with System.Web.UI.&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;COLOR:#2b91af;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;Page . Whan i tryed to change to user control i got &lt;/span&gt;&lt;span style="FONT-SIZE:12pt;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:12pt;COLOR:#2b91af;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;error here &lt;/span&gt;&lt;span style="FONT-SIZE:12pt;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;COLOR:#2b91af;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;AbstractClass&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt; page = (&lt;span style="COLOR:#2b91af;"&gt;AbstractClass&lt;/span&gt;)Page;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;int&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt; iResult = page.DoSomething();&lt;/span&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;span style="FONT-SIZE:10pt;COLOR:#2b91af;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;so how can i &lt;/span&gt;&lt;span style="FONT-SIZE:10pt;COLOR:black;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;inherits&amp;nbsp;&amp;nbsp; user control and page base class to Abstract user control&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Re: How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/2542343.aspx</link><pubDate>Thu, 07 Aug 2008 07:25:50 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2542343</guid><dc:creator>Leyu</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2542343.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=2542343</wfw:commentRss><description>&lt;p&gt;If you are using the UserControl from one page only this is not much of a problem because you can call the Methods of the Page&lt;/p&gt;&lt;p&gt;by directly casting them to the Page in which you are going to the UserControl &lt;br /&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public&lt;/span&gt; partial &lt;span class="kwd"&gt;class&lt;/span&gt; UserControl_WebUserControlA : System.Web.UI.UserControl
{
    &lt;span class="kwd"&gt;protected void&lt;/span&gt; Page_Load(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
	MySpecificPage page = (MySpecificPage)Page;
	page.BindData();
	page.BindData2();

	&lt;span class="cmt"&gt;// Any other method defined in the specific page...  &lt;/span&gt;
    }
}&lt;/pre&gt;&lt;pre class="coloredcode"&gt;If your intention is to use the UserControl in multiple pages I favor using the Contracts defined by Interfaces implemented by different classes&lt;/pre&gt;&lt;pre class="coloredcode"&gt;and you can throw NotImplementedException() for some of the methods which a specific Page might not implement or you can defined multiple Interfaces&lt;/pre&gt;&lt;pre class="coloredcode"&gt;of which the UserControl is aware of and do things differently.&lt;/pre&gt;&lt;pre class="coloredcode"&gt;Note that a class can implement multiple interfaces&lt;/pre&gt;&lt;/pre&gt;</description></item><item><title>Re: How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/2542293.aspx</link><pubDate>Thu, 07 Aug 2008 07:02:29 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2542293</guid><dc:creator>amitsplash@gmail.com</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2542293.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=2542293</wfw:commentRss><description>&lt;p&gt;what if I have different functions to call for different cases like in first form we have BindGrid() method to call and in second class we have BindGrid and BindGridData() to call&lt;/p&gt;</description></item><item><title>Re: How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/2513800.aspx</link><pubDate>Fri, 25 Jul 2008 07:25:07 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2513800</guid><dc:creator>moredotnet</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2513800.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=2513800</wfw:commentRss><description>Simply Awesome!</description></item><item><title>Re: How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/1904458.aspx</link><pubDate>Wed, 12 Sep 2007 09:30:19 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1904458</guid><dc:creator>Eustaquio</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1904458.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=1904458</wfw:commentRss><description>&lt;p&gt;Great solution. Thanks a lot.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/1904368.aspx</link><pubDate>Wed, 12 Sep 2007 08:19:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1904368</guid><dc:creator>Thomas Sun – MSFT</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1904368.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=1904368</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Based on my understanding, you want to know how to call the method that is declared on the page from UserControl. If I have misunderstood you, please feel free to let me know.&lt;/p&gt;
&lt;p&gt;We can call the method that is declared on the page from UserControl in the asp.net 2.0. For example, we can create an abstract base class for the Page in the App_Code folder. The following is the abstract base class which will be inherited by the Page:&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="cmt"&gt;/// &amp;lt;summary&amp;gt;
/// Summary description for AbstractBaseClass
/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="kwd"&gt;public abstract class&lt;/span&gt; AbstractBaseClass : &lt;strong&gt;System.Web.UI.Page&lt;/strong&gt;
{
	&lt;span class="kwd"&gt;public&lt;/span&gt; AbstractBaseClass()
	{
		&lt;span class="cmt"&gt;//
		// TODO: Add constructor logic here
		//&lt;/span&gt;
	}

 &lt;strong&gt;   &lt;span class="kwd"&gt;public abstract int&lt;/span&gt; DoSomething();&lt;/strong&gt;
}&lt;/pre&gt;&amp;nbsp; 
&lt;p&gt;In the Page, we need to inherit this base class and override the abstract method declared in the base class:&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public&lt;/span&gt; partial &lt;span class="kwd"&gt;class&lt;/span&gt; UserControl_Default : &lt;strong&gt;AbstractBaseClass&lt;/strong&gt;
{
    &lt;span class="kwd"&gt;protected void&lt;/span&gt; Page_Load(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {

    }

&lt;strong&gt;    &lt;span class="kwd"&gt;public override int&lt;/span&gt; DoSomething()
    {
        &lt;span class="kwd"&gt;return&lt;/span&gt; 1 + 1;
    }&lt;/strong&gt;

    
}&lt;/pre&gt;&amp;nbsp; 
&lt;p&gt;In the UserControl, We just need to call the method which exists in the base class: &lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public&lt;/span&gt; partial &lt;span class="kwd"&gt;class&lt;/span&gt; UserControl_WebUserControlA : System.Web.UI.UserControl
{
    &lt;span class="kwd"&gt;protected void&lt;/span&gt; Page_Load(&lt;span class="kwd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
&lt;strong&gt;        AbstractBaseClass page = (AbstractBaseClass)Page;
        &lt;span class="kwd"&gt;int&lt;/span&gt; iResult = page.DoSomething();&lt;/strong&gt;
    }
}
&lt;/pre&gt;&amp;nbsp; 
&lt;p&gt;&lt;br /&gt;I hope this helps.&lt;/p&gt;</description></item><item><title>Re: How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/1901310.aspx</link><pubDate>Mon, 10 Sep 2007 17:00:09 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1901310</guid><dc:creator>Eustaquio</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1901310.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=1901310</wfw:commentRss><description>&lt;p&gt;Thanks but I need a public or protected method, not static, from event in user control and i have an instance of page, this is page property of user control that is a pointer to container page.&lt;/p&gt;
&lt;p&gt;The problem is that the page property is a Page class and i need to cast to MyPage to access it`s public methods or properties.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/1901276.aspx</link><pubDate>Mon, 10 Sep 2007 16:41:36 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1901276</guid><dc:creator>machta</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1901276.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=1901276</wfw:commentRss><description>&lt;p&gt;This is calling static method, not public. So you can replace &lt;strong&gt;&lt;strike&gt;public&lt;/strike&gt;&lt;/strong&gt; with &lt;strong&gt;static&lt;/strong&gt; and&amp;nbsp;use &lt;u&gt;NameSpace.Class.Method()&lt;/u&gt; to call this method.&amp;nbsp;(For calling non static method you have to use istance of the class.)&lt;/p&gt;
&lt;p&gt;You want to call this method from event?&lt;/p&gt;
&lt;p&gt;(I didn&amp;#39;t completely understand your question - I didn&amp;#39;t use asp.net 1.1)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>How can i to call a public method of page from user control?</title><link>http://forums.asp.net/thread/1901253.aspx</link><pubDate>Mon, 10 Sep 2007 16:23:18 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1901253</guid><dc:creator>Eustaquio</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1901253.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=1901253</wfw:commentRss><description>&lt;p&gt;In asp.net 1.1 it´s easy: ((PageNameSpace.PageClass)Page).PublicMethod()&lt;/p&gt;
&lt;p&gt;but in asp.net 2.0 I don´t know to do it.&lt;/p&gt;</description></item></channel></rss>