Call public method on aspx page from a web control embedded in the page

I have a nut to crack.

How do I call a public method on my aspx page from my web control, the web control is embedded into the page.

The markup looks like this:-  

 
1    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
2    <ContentTemplate>
3    <asp:Xml ID="Xml1" runat="server"></asp:Xml>
4    <uc2:tier3menu ID="menu1" runat="server" />
5    </ContentTemplate>
6    </asp:UpdatePanel>
I wrote an itemcommand thingie in the web control that needs to set the Documentsource and Transformsource on the asp:Xml
The help is much appreciated!
0
midwinter
4/17/2008 2:16:45 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

3 Replies
923 Views

Similar Articles

[PageSpeed] 29

Hi midwinter,

you can use an event check the msdn .net library to fin the sutable one, in the event put the method name (event="methodName")

a event method is writen like this;

protected void methodName(object sender, EventArgs e)
{
        // some code
}

If you all redy have a public method you can write a overload (same name with diffrent parameters).

public void methodName()
{
        // some code
}

protected void methodName(object sender, EventArgs e)
{
       methodName();
}

Let me know if this helps.


Simon Deshaies

Support Specialist / Support C# Analyst at Nstein Technologies

weblog.simondeshaies.net

Please remember to click “Mark as Answer” on the post that helps you.


0
Simon
4/17/2008 3:03:39 PM

To clarify my question, assuming that I have a public method on the aspx page 

1    public void SetContent(string xml, string xslt)
2    {
3       Xml1.DocumentSource = xml;
4       Xml1.TransformSource = xslt;
5    }

 How do I call it from inside the webcontrol? Can I just call it like that?

0
midwinter
4/17/2008 6:28:04 PM

I'm sorry I read fast and mistaken web control for web page. Your web control is a class, right?

public class MyWebControl: WebControl...

So a public method of a class can be called from any other class.

The web page code behing class is a public partial class. partial is use to split one class in many files, parts, and every method are availeble to the other parts. I understand that you can call your method as it is.

Did you try it? If so what hapen?

MSDN: Using the partial keyword indicates that other parts of the class, struct, or interface can be defined within the namespace. All the parts must use the partial keyword. All of the parts must be available at compile time to form the final type. All the parts must have the same accessibility, such as public, private, and so on. If any of the parts are declared abstract, then the entire type is considered abstract. If any of the parts are declared sealed, then the entire type is considered sealed. If any of the parts declare a base type, then the entire type inherits that class. All of the parts that specify a base class must agree, but parts that omit a base class still inherit the base type. Parts can specify different base interfaces, and the final type implements all of the interfaces listed by all of the partial declarations. Any class, struct, or interface members declared in a partial definition are available to all of the other parts. The final type is the combination of all the parts at compile time.
http://msdn2.microsoft.com/en-us/library/wa80x488(vs.80).aspx

Hope this help. let me know.


Simon Deshaies

Support Specialist / Support C# Analyst at Nstein Technologies

weblog.simondeshaies.net

Please remember to click “Mark as Answer” on the post that helps you.


0
Simon
4/17/2008 8:03:55 PM
Reply:

Similar Artilces:

Can my web page with a form submit to other web pages forms?
I was wondering if I created an aspx page that had a form on it that I could use the submit button to submit this form's contents to other web pages forms(servers accepting those form's data). I am thinking this would be a great way to update data on particular web pages without having to actually visit those similar web pages. Any ideas, examples would be much appreciated. Thanks in advance.  Yes you can.  It's called Cross Page Posting: http://msdn2.microsoft.com/en-us/library/ms178139.aspxAlso: http://msdn2.microsoft.com/en-us/library/ms178140.aspx might ...

Web Menus / User controls in aspx web page and .aspx C# based web templates
Dear all, I have created several user controls and included in the webpages. (This user control is a navigation menu consisting of images) This has to be included in all webpages. But when i tried to publish i get error messages for them. But i can’t remove since i need these user controls. Error message given below Error 2 The type 'WebUserControl' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\new_latest\d203e69a\d67c356f\App_Web_ijsq-eqk.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\new_la...

Web page .aspx is slow when loading. Pages have web user controls on them that are loaded dynamically
I have written a web application using VS 2003. Several of my forms have web user controls on them. The controls are loaded dynamically at runtime. The problem is that the web pages are very slow to load. Does anyone know if there is a way to speed up the pages being loaded into the browser? Here is an example of some code I use to dynamically load the controls:  private void Page_Load(object sender, System.EventArgs e)  {   // Put user code to initialize the page here   // Put user code to initialize the page here    Co...

Urgent!!! Form inside Windows form control (that is embedded to Web page i.e aspx), not displayed on button click
 Hi all I have a Windows Form Control(i.e Windows Control Library), that consists of a Button "button1" and  a panel "panel1". Also I have a form "form1.cs". On form "form1.cs" I have a label whose text value i have set to  "Hi". On click of button "button1" on windows form control i am opening the form "form1.cs"  inside a panel and it displays "Hi". The code of windows form control is as below :  public partial class UserControl1 : UserControl    {    ...

Can I have a web user control call a method on the page it's parent page?
I'm building an application where I'm using serveral different controls on a page and as one of them causes a postback I may want the page to make changes to other controls.  Is there a way to either fire and event off from the control that the page could then capture or simply have the control call a method of it's parent page? Obviously the Page object is there to work with, but I can't seem to figure out how to specifically cast it as a specific page.  For real man, In your user control you need to create a public event which is raised by the event of the...

error when calling a web services method from a winform control in an aspx page
I've put a winform control into an aspx page, inside an 'object' tag and I'm having it call a web service method.The control runs fine when I debug it in VS, and the control itself loads into the web page when I view it over the internet in IE, but when I click the button to call the web services method (it  sends a string to a label in the control) I get the following error message...and the string is not returned to the label...System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToke...

how to open a web page in form of a popup web page
Hello, I have two web pages, let say. Page A : With a Button on it. PAge B: with some info. Now I need to: When I click on the Button of page A.Page B must open in a pop up window.  I can do this but problem is this when I clicked on the button for first time it does not show me any thing and when I clicked on the button for second time then It shows me Page B .My code is as follow:  1 protected void Page_Load(object sender, EventArgs e) 2 { 3 if (!this.Page.IsPostBack) 4 { 5 6 } 7 else 8...

All web pages hang on web server when one of the web pages calls a run away sql query
Hi: We have a Windows 2003 dedicated web server running the .NET Frameworks 1.0 and 2.0.  We have a SQL Server cluster running SQL Server 2000.  Unfortunately, we do not have a test environment.  I have 2 .NET web sites in production.  My coworker has a voting .NET web page using AJAX on the same server.  The coworker wrote a query that was not indexing properly and when the page fired the query...the cluster went to almost 100% utilization.  My two web pages would hang and show a blank white page on the default.aspx.  Neither of m...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

Calling a method from a control page on the axpx page where the control page exists.
Hello,  I have an .aspx page that has a method called grdMain_DataBind().  I have a control page that loads within the aspx page which has its own logic.  I have a button on my control page called "SAVE".  How can I call the method grdMain_DataBind thats in my aspx logic from the control that exists on that page when I click SAVE button.  Is there a way? If I were you, I'd simply create a "Save" Event within your control. When the Button in your control is pressed, in the Click handler for that Button you can raise the event. Then, within t...

Single page with multiple user web controls VS Multiple page with specific user web controls
I have a question regarding single page with multiple user web controls vs multiple page with specific user web controls   Option 1: I am of the opinion to have multiple pages with specific user web controls and use an object to store all the information as the user navigates through the application. And finally at the end, read this object and save all the information to the backend database.   Option 2: My respected team member suggests that we have only one page, with all the specific user web controls and not use an object, instead show/hide the user web controls based ...

How to databind control in one web page from another web page
Hi all,  I have a listbox control and a button control in a web page. Once the user clicks the button another web page is opened. The new web page will accept some data from the user which will be used to databind the listbox in the first web page. In other words, the two web pages ( the parent window and the child window) are open at the same time. The child page needs to databind a control in the parent page. Is there a way to do it? I need some code. Thx in advance Update: I hate to do this. Looks like I will have to take help of viewstate and session si...

Call codebehind method from aspx page OR call javascript function of usercontrol control from page
Hi, I have a page which contains a user control.  When a user clicks on a submit button, I'd like to detect when elements in the user control have changed and popup a message box if changes have been detected to confirm if the user wants to save the changes. Obviously the message box is executed using javascript.  But I'd really like to be able to call a method in the code behind of the page which queries the user control if it has changed.  Is there a way of calling the code behind method from within a javascript function? Otherwise, if I make all the functions execut...

controlling an object in a web control from the page the web control is placed in
I have created a web control in vb.net that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

Web resources about - Call public method on aspx page from a web control embedded in the page - asp.net.web-forms

GNOME Mobile & Embedded Initiative - Wikipedia, the free encyclopedia
... about the topic. If notability cannot be established, the article is likely to be merged , redirected , or deleted . The GNOME Mobile & Embedded ...

Facebook To Page Admins: Link Share Posts Draw More Engagement Than Embedded Links
Facebook’s latest advice to page administrators focused on declining organic reach involves the way they share links . continued… New Career ...

Embedded Posts Now Available to Everyone
We introduced Embedded Posts in July to make it easy for publishers to add any public post from Facebook to their blog or web site. Today, we're ...

Facebook gives embedded posts a visual renovation
Post by ESPN . Facebook rolled out embedded posts last year , and today the company has announced a more aesthetic redesign . Now, photos and ...

Embedded.com (@embedded_com) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Embedded.com @ embedded_com ...

Rich photo experience now in embedded Tweets - Twitter Blogs
Every day, publishers and journalists all over the world share the best of Twitter with their readers by embedding Tweets in their articles. ...

Embedded Timelines - Twitter Developers
Overview Embeddable timelines make it easy to syndicate any public Twitter timeline to your website with one line of code. Just like timelines ...

Embedded Systems Design - LinkedIn
Embedded Systems Design was created specifically to meet the information needs of the senior-level developers who create complex embedded systems. ...

App Store - Embedded Computing Design
Get Embedded Computing Design on the App Store. See screenshots and ratings, and read customer reviews.

VIA Embedded booth digital home - Flickr - Photo Sharing!
Stylish, discreet digital home automation, security and entertainment solutions on show at the VIA Embedded booth at Computex 2009

Resources last updated: 12/20/2015 5:48:35 PM