473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Master Pages VB.net 2005

Hello,

I am starting to use Master pages. I understand the concept that these
pages should remain passive. So, I need a little assistance.

Scenario:

1. Master page with a search box & submit button
2. several pages that use this master page
3. based on the value placed in the search box, I want to refresh the data
on the page shown.

Question:

On the page that is using this master page, how do I capture the click event
of the submit button from the master? I am using a public property to get
the value of the box.

Am I just overlooking something simple or just out in left field?

Thanks in advance!!
Jan 24 '07 #1
4 5583
Hi Jeff,

You can expose the submit button and the search text to the content page.
The content page hooks up the submit button's click event and retrieves the
searched text:

MasterPage2.master:

<%@ Master Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Public ReadOnly Property SearchButton() As Button
Get
Return btnSearch
End Get
End Property

Public ReadOnly Property SearchText() As String
Get
Return txtSearch.Text
End Get
End Property
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox><asp:Button
ID="btnSearch" runat="server" Text="Search" />
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
Default3.aspx:

<%@ Page Language="VB" MasterPageFile="~/MasterPage2.master"
Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPage2.master" %>

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
AddHandler Master.SearchButton.Click, AddressOf SearchButton_Click
End Sub

Private Sub SearchButton_Click(ByVal sender As Object, ByVal e As
EventArgs)
Label1.Text = Master.SearchText
End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Label ID="Label1" runat="server"></asp:Label>
</asp:Content>
For more information about Master Pages, please see following article:

#ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps
http://www.odetocode.com/Articles/450.aspx
Hope this helps.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 25 '07 #2
I read the article you sent the link too, but did not see an answer to
one of the questions I have on Master pages.

I would like to be able to have the Images and text on the master page
load from entries in a database.
I have not been able to get the code to execute and load the data.
What is the trick for doing this?

Robert

Jan 25 '07 #3
Walter,
Thanks for the info. I will give it a try.
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:Wd**************@TK2MSFTNGHUB02.phx.gbl...
Hi Jeff,

You can expose the submit button and the search text to the content page.
The content page hooks up the submit button's click event and retrieves
the
searched text:

MasterPage2.master:

<%@ Master Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Public ReadOnly Property SearchButton() As Button
Get
Return btnSearch
End Get
End Property

Public ReadOnly Property SearchText() As String
Get
Return txtSearch.Text
End Get
End Property
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox><asp:Button
ID="btnSearch" runat="server" Text="Search" />
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
Default3.aspx:

<%@ Page Language="VB" MasterPageFile="~/MasterPage2.master"
Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPage2.master" %>

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
AddHandler Master.SearchButton.Click, AddressOf SearchButton_Click
End Sub

Private Sub SearchButton_Click(ByVal sender As Object, ByVal e As
EventArgs)
Label1.Text = Master.SearchText
End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Label ID="Label1" runat="server"></asp:Label>
</asp:Content>
For more information about Master Pages, please see following article:

#ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps
http://www.odetocode.com/Articles/450.aspx
Hope this helps.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Jan 25 '07 #4
Walter, This is perfect. I was totally overcomplicating things on my end.
Sometimes I get wrapped up in my own confusion.

THIS GROUP ROCKS!!

:-)
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:Wd**************@TK2MSFTNGHUB02.phx.gbl...
Hi Jeff,

You can expose the submit button and the search text to the content page.
The content page hooks up the submit button's click event and retrieves
the
searched text:

MasterPage2.master:

<%@ Master Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Public ReadOnly Property SearchButton() As Button
Get
Return btnSearch
End Get
End Property

Public ReadOnly Property SearchText() As String
Get
Return txtSearch.Text
End Get
End Property
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox><asp:Button
ID="btnSearch" runat="server" Text="Search" />
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
Default3.aspx:

<%@ Page Language="VB" MasterPageFile="~/MasterPage2.master"
Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPage2.master" %>

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
AddHandler Master.SearchButton.Click, AddressOf SearchButton_Click
End Sub

Private Sub SearchButton_Click(ByVal sender As Object, ByVal e As
EventArgs)
Label1.Text = Master.SearchText
End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Label ID="Label1" runat="server"></asp:Label>
</asp:Content>
For more information about Master Pages, please see following article:

#ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps
http://www.odetocode.com/Articles/450.aspx
Hope this helps.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Jan 25 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
3
by: Mike Dee | last post by:
I posted this back in November 2005 a couple times but did not get any responses. I'm hoping someone here can please shed some light on this. I'm new to index server and can't get any DocTitle...
9
by: Andrew Kidd | last post by:
Hi, I've just been working through several examples of how to create Master pages and then create content pages which are linked, but I cannot see the Master page when I'm viewing the content...
1
by: LilC | last post by:
I'm creating an application that has a standard layout for all pages. The information that is displayed in the layout will be dynamic based on the user that is logged in. Thus when a page is...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
5
by: Ryan | last post by:
Is there any way to apply a master page to existing pages that weren't previously using a master page? VB 2005. Thanks, Ryan
3
by: Rolf Welskes | last post by:
Hello, for a large web site project we would like to use nested Master Pages. Unfortunely VS2005 is not able to show pages in design mode when nested Master pages are used. This has the...
8
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
2
by: shapper | last post by:
Hello, I have 2 pages: Page1.aspx and Page2.aspx. The two pages have common design parts but also not common design parts. Is it possible to create something like this: MasterPageA |
4
by: daveh551 | last post by:
I've seen reference to Nested Master Pages in some of the documentation, but I haven't been successful in creating one in VS 2005 (Framework 2.0). I just did a search on it, and "How To:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.