CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 5/15/2006 1:56:34 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 4 Views: 181 Favorited: 0 Favorite
5 Items, 1 Pages 1 |< << Go >> >|
rizwanaslamdar
Asp.Net User
Sub Page_Load - not working in the content page.5/15/2006 1:56:34 AM

0

Hi there,

I am using a content page (tellafriendaction.aspx) which uses a master page (PublicMaster.Master)

The masterpage Page_Load event (in the code behind page) is working and is called when tellafriendaction.aspx page is called.

But the Page_Load event in the content page (tellafriendaction.aspx) is not working or is not called when i call the content page while i am debugging the application.

(Note: I have an html form in TellAFriend.aspx content page. It submits the form to TellAFriendAction.aspx page, which should capture the form content and send the friend an email message.)

Here is some code samples:

=================
tellafriendaction.aspx.vb (code behind page for the content page)
==================

Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Net.Mail

Partial Class tellafriendaction
    Inherits System.Web.UI.Page

    Sub Page_Load 'this method is not being called WHY?
        Dim emailFromAddress As String = Master.Request.Form("txtFromEmailAddress")
        Dim emailToAddress As String = Master.Request.Form("txtToEmailAddress")
        Dim fromName As String = Master.Request.Form("txtFromName")
        Dim emailMessage As String = Master.Request.Form("txtMessage")
        lblResponse.Text = "success"
    End Sub
End Class


================
content page top portion for tellafriendaction.aspx
===============
<%@ Page Language="VB" MasterPageFile="~/PublicMasterPage.master" AutoEventWireup="false" CodeFile="tellafriendaction.aspx.vb" Inherits="tellafriendaction" title="Tell A Friend" %>

<%@ Register TagPrefix="ForbesVIP" TagName="TopNavigation" Src="topnavigation.ascx" %>
...............
..........
............
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<img src="images/pixel.gif" height="18" border="0"><br>
        <strong>Spread the word!</strong><br>
        <asp:Label id="lblResponse"  runat="server"/>
        <br>
        <img src="images/pixel.gif" height="30" border="0"><br>
</asp:Content>

=========================

Question 1:
The  Page_Load method of TellAfriendaction.aspx.vb is not being called when i am debugging. It seems that while i am debugging that the Page_Load method of the master page is being called but it somehow skips the Page_Load method of tellafriendaction.aspx.vb page.

Any ideas what i am doing in the above code?

Question 2:
Is it correct to use the statement:
Master.Request.Params("something")
in the above code behind page code?


Thanks

Rizwan






Target
azamsharp
Asp.Net User
Re: Sub Page_Load - not working in the content page.5/15/2006 5:08:35 AM

0

I am not really sure that what is stopping the debugging of the application. Please a break point on the Page_Load event and try again. Does it reach there?

Create a button on the webform and check that if the debugging is working for the button click code.

I think you should use the following code :

Page.Request.Form("txtFromEmailAddress");

If the txtFromEmailAddress is a simple asp web server textbox control then you can retrieve the value usin the following code:

string email = txtFromEmailAddress;








Hope it helps!
AzamSharp
Microsoft Certified Professional
My Blog
KoffeeKoder
Interested in writing for KoffeeKoder! Email me!
orzeh
Asp.Net User
Re: Sub Page_Load - not working in the content page.5/15/2006 7:33:44 AM

0

hi!

the method is not correctly defined, it should be:

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' code
End Sub

orzeh




code less, think more!
rizwanaslamdar
Asp.Net User
Re: Sub Page_Load - not working in the content page.5/15/2006 3:45:39 PM

0

Thank you Orzeh,
Yes the method signature was not correct. Now it's working perfectly.

EXCEPT one item. dont know if you would be able to help or not.

Please refer to the code in my previous email.
I have a masterpage and a content page.

I have tellafriend.aspx content page with a simple HTML form which posts data (apparently) to tellafriendaction.aspx content page.

Both of the above pages use the same master page.

In tellafriendaction.aspx.vb code behind page I am using:

Dim fromEmailAddress As String = Request.Form("txtFromEmailAddress")

I also used to test:

Dim fromEmailAddress As String = Page.Request.Form("txtFromEmailAddress")

But both of these above statements are not capturing the form value of txtFromEmailAddress which tellafriend.aspx is trying to submit.

Any ideas?

Rizwan






Target
MorningZ
Asp.Net User
Re: Sub Page_Load - not working in the content page.5/15/2006 4:17:03 PM

0

This article needs to be hot-linked on every single post in this "MasterPage" forum

http://www.odetocode.com/Articles/450.aspx

Read that, especially the part that is about 2/3rds down the page ("FindControl, Javascript, and NamingContainers"), it will explain why you cannot find "txtFromEmailAddress"


"If you make it idiot proof, they'll build a better idiot"
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Professional ASP.NET 3.5: In C# and VB Authors: Bill Evjen, Scott Hanselman, Devin Rader, Pages: 1673, Published: 2008
ASP.NET Unleashed: unleashed Authors: Stephen Walther, Pages: 1488, Published: 2003
Pro VB 2008 and the .NET 3.5 Platform Authors: Andrew Troelsen, Pages: 1377, Published: 2008
Mastering Web Development with Microsoft Visual Studio 2005 Authors: John Paul Mueller, Pages: 822, Published: 2005
Learning ASP.NET 3.5 Authors: Jesse Liberty, Dan Hurwitz, Brian MacDonald, Pages: 576, Published: 2008
ASP.NET: Tips, Tutorials, and Code Authors: Scott Mitchell, Pages: 878, Published: 2002
Mastering Dreamweaver MX Databases Authors: Susan Sales Harkins, Bryan Chamberlain, Darren McGee, Pages: 707, Published: 2003
ASP.NET in a Nutshell: In a Nutshell Authors: G. Andrew Duthie, Matthew MacDonald, Pages: 979, Published: 2003
Sams Teach Yourself ASP.NET in 21 Days Authors: Chris Payne, Pages: 1104, Published: 2002

Web:
Sub Page_Load - not working in the content page. - ASP.NET Forums Sub Page_Load - not working in the content page. Last post 05-15-2006 12:17 PM by MorningZ. 4 replies. Sort Posts: ...
FindControl not working within a content page - ASP.NET Forums Re: FindControl not working within a content page .... Page Sub Page_Load() Dim imgName As String = "Image1" Dim imgImage As Image ...
Master Page Method: Code-Behind for Content Page - WebDeveloper.com Partial Class content Inherits System.Web.UI.Page Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not Page. ...
Postback not working, pages not maintaining state - I entirely don ... end sub So this is how I see this: - Load the page, build its content in Page_Load ... Private Sub Page_Load() If Not Page.IsPostBack Then ...
How to add programmatically a label into a content page? - .NET VB Let me know if it's not working. On Mar 8, 5:31 pm, "Phil" ASP.net content page event called before page load My problem is that the page load event of the content page is called before my custom event .... If Not Page.IsPostBack Then SetupToolbar() End If End Sub ...
Microsoft Expression Expression Web Request.Form ASP 2.0 problem ... I think the problem may be with Page_Load not working as intended with .... that "The page contains nested content controls which are not supported in the ...
In-place Updating in Datagrid not working Apr 7, 2005 ... Page Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System. .... the content is not changed. Show quoteHide quote ...
.NET ASP.NET FindControl not working Here's my code: Protected Sub Page_Load(ByVal sender As Object, .... the hyperlinks are all within a content page, not the MasterPage. ...
W3Schools Forum > Disable Submit Button w/OnClientClick: Not Working Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) If Not Page. ... This is a "lo-fi" version of our main content. To view the full version with ...






shopping cart - build or buy?

label message in vb containing href giving end of statement expected error

why doesn't this function work

formatting numbers from a textbox in c#

trouble with a foreach and directory services

wondering how to copy files about and upload them

ado.net

adding a line break to a placeholder

user control problems

application_error not fireing with unhandled error, but does use configured redirect page

reading web.config out of a custom control

drill down report incorporating freetextbox

site scraping

net automatic properties

would like to suggest some video tutorial topics please

specified web server is not running asp.net version1.1

createuserwizard

how to make a form postback from a popup

asp.net forum????

reading sms

questions about the data tutorial on the learn section of asp.net site

different width settings for dynamic submenus

how to avoid user input not numetric data to textbox?

db calls issue

how to remove xtra connection strings

clientscript not working

how can it be? there is not a control to display messages from the server.

textboxes

using collection<t> + asp.net 2.0+c#

sort of calculation grid

   
  Privacy | Contact Us
All Times Are GMT