Showing posts with label together. Show all posts
Showing posts with label together. Show all posts

Thursday, March 29, 2012

passing values from main webform to include template pages

View a printable version of this message!I'm new to ASP.Net... I have a web page (myform.aspx) that is put together using 3 include files, header.cscx, left.cscx, & footer.cscx (each has their own .cscx.vb files). I want to assign some custom values on myform.aspx.vb, how can I get these custom values in my one of my includes files, ie. header.cscx.vb?
'**********This is myform.aspx*************
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="footer" src="http://pics.10026.com/?src=footer.ascx"%>
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="left" src="http://pics.10026.com/?src=left.ascx"%>
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="header" src="http://pics.10026.com/?src=header.ascx"%>
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" Codebehind="myform.aspx.vb" Inherits="intranet.myform"%>
<UC:header id="header" runat="server" />
<UC:left id="left" runat="server" />
<TABLE><TR><td>My contents go here...</td></TR></TABLE>
<UC:footer id="footer" runat="server" />

'**********This is myform.aspx.vb*************
Public Class myform
Inherits System.Web.UI.Page
Protected WithEvents lblPageTitle As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblPageTitle.Text = "Welcome to my home page!"
End Sub
End Class

'**********This is header.ascx*************
<%@dotnet.itags.org. Control Language="vb" AutoEventWireup="false" Codebehind="header.ascx.vb" Inherits="intranet.header" %>
'I don't have any HTML code here yet (all are in header.acsx.vb) b/c I'm still working on the sepration between HTML design and codebehind page.

'**********This is header.ascx.vb*************
Public Class header
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'How can I get the value of lblPageTitle here so I can display it in the HTML Title tag??
'I have other values that I want to pass to this page too, but for this example, I'm just trying to get the value of lblPageTitle from myform.aspx.vb
Response.Write("<HTML><HEAD>")
Response.Write("<title>lblPageTitle</title>")
Response.Write("</HEAD><BODY>")
...
End Sub
End Class1) Cookie
2) Session Variable
3) Query String
I think any of these will work for what you're describing. You'retrying to get som value to be accessible to your user controls from themain page.

Have you thought of using properties inside the usercontrols?
check this please:
An Extensive Examination of User Controls
The best reference to UserControls
Regards
Thank you so much, it's exactly what I need!
That is great, Im happy for you.
regards

Monday, March 26, 2012

Passing Variable Across Secure Pages

Hey Bros:

I'm new to asp.net obviously, and am working on trying to put together my first website. I need help passing variables across multiple forms then trying to query a sql database based on the data which is passed.

What I have is
page one, datalist with a button when clicked will redirect to a page in a directory protected using forms authentication, user will be redirected to log in, once logged in the are redirected to the original destination page.

page two, will show the items, and details of the page which corresponds to the button the visitor originally choose.

I know I basicly have to create something to grab the value on the original page, and then on the destination page create something to grab the value, then perform an SQL statement agianst the value which was orignally grabbed from the first page. I just cannot find code which I can understand to do this. Any help would be greatly appreciated!Well one step at a time will take you far places...

You can easily preserve the data in a form item by enabling viewstate on the form by adding the following syntax enabledviewstate="true" This uses more system resources though and should not be enabled for form items that do not need it.

You were saying that you want to pass data from here to there etc... Well in asp.net you really do not have to and can code your entire program into one asp.net which eliminates passing values to and from. Ever hear about asp.net panels? A good book I would recommend is ASP.NET UNLEASHED by: Stephen Walther, if you are just starting out... I will track this thread to see if you have any other Q's...