Link to home
Start Free TrialLog in
Avatar of derftoy
derftoyFlag for United States of America

asked on

Calling a function on a master page from my child page

I have a master page that I am using like a wizard.  at the bottom of my master page I have a BACK and NEXT button.  The pages could be in any order and could be 1 to many pages as the user can customize the steps in the wizard.  I have about 5 different pages that have user controls and such on those pages for the user to enter data, like contact information for the applicant, and then they click next and then the property owner, etc...   I used to have this as seperate pages with pretty much the same code on each page and I am moving it to a master page.

The problem is that when the user clicks next, it needs to save data to the database or perform other functions for the content entered.  But my NEXT button is on my master page.  I would like the next button to call an UPDATE function on my child page before it moves to the next URL for processing.  I am doing this in VB.NET.

Is this possible?
Avatar of joeylu
joeylu

As general, you can call your page control from master page by using the findcontrol, let's say you have this image button on your master page named "bn_next" with onclick property to bn_Next_Click, and in your child page, there's a label named "LabelMenu"

Protected Sub bn_Next_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
       
        Dim ThisLabel As Label
        ThisLabel = CType(ContentPlaceHolder1.FindControl("LabelMenu"), Label)
        ThisLabel.Text = "Profile"
       
End Sub



you can read more about this from this link, http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx
Avatar of derftoy

ASKER

Your sugestion is changing the property of a control.  I want to call an UPDATE method in the Code Behind on the Child page.  That way, any information entered into text boxes and such are entered into the database and then the next event will then redirect to another URL.
just make a function in another class file and call it from where you like.
just make a function in another class file and call it from where you like.
1. Add public method into your master page code-behind
public void test(){  }

2.Use MasterType directive in your content page
<%@ MasterType VirtualPath="~/MasterPage.master" %>

3. Add call of MasterPage method inside your content page code-behind
Master.test();

Also you can use properties defined in MasterPage if you need ysing the same way.
If you want to access MasterPage controls you need to use FindControl or add MasterPage method like test() described above which able to access controls directly
ASKER CERTIFIED SOLUTION
Avatar of derftoy
derftoy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial