.NETGURU
Getting a value from an ascx
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngreuse' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Damian Barrow
Hi all, this is probably easy but I just can't figure it out.

I have a person_info page, and all I do is copy a template page to a
directory in the name of the person (using FSO at the moment) so that
they can access their details by folder, rather than ID (eg
www.travelcounsellors.com/briant

The page is an ASPX and too complicated to muck about with, so I want an
ASCX in the same directory that I can simply say Person_id =3D 123, and
then use that id in the ASPX page to get all the details.

Can I do this (I could in an include I know) but I want to be able to
later on use richtextbox (www.richtextbox.com) to let the homeworkers do
rich html pages.

I'm looking for something like (in simple form):

ASPX:
<%@ Page Language=3D"VB" %>
<%@ import Namespace=3D"System.IO" %>
<%@ Register TagPrefix=3D"personID" TagName=3D"personBit"
Src=3D"/deleteme.ascx" %>
<personID:personBit id=3D"personID" runat=3D"server" />

<script runat=3D"server">
lblPErsonID.Text =3D Person_id
</script>

<html>
<head>
</head>
<body>
<form runat=3D"server">
<asp:Label id=3D"lblPErsonID" runat=3D"server">Label</asp:Label>
<!-- Insert content here -->
</form>
</body>
</html>

ASCX:
<%@ Control Language=3D"VB" %>
<script runat=3D"server">

Dim person_id as Integer
person_id =3D 717

</script>

Any help appreciated
Damian

Reply to this message...
 
    
Damian Barrow
-- Moved from [aspngfreeforall] to [aspngreuse] by devin <Click here to reveal e-mail address> --

Hi all, this is probably easy but I'm having problems with it.

It's a person page, and all I do is copy a template page to a directory
in the name of the person (using FSO at the moment)

The page is an ASPX and too complicated to muck about with, so I want an
ASCX in the same directory that I can simply say Person_id =3D 123, and
then use that id in the ASPX page to get all the details.

Can I do this (I could in an include I know).

I'm looking for something like:

ASPX:
<%@ Page Language=3D"VB" %>
<%@ import Namespace=3D"System.IO" %>
<%@ Register TagPrefix=3D"personID" TagName=3D"personBit"
Src=3D"/deleteme.ascx" %>
<personID:personBit id=3D"personID" runat=3D"server" />

<script runat=3D"server">
lblPErsonID.Text =3D Person_id
</script>

<html>
<head>
</head>
<body>
<form runat=3D"server">
<asp:Label id=3D"lblPErsonID" runat=3D"server">Label</asp:Label>
<!-- Insert content here -->
</form>
</body>
</html>

ASCX:
<%@ Control Language=3D"VB" %>
<script runat=3D"server">

Dim person_id as Integer
person_id =3D 717

</script>

Cheers
Damian

Reply to this message...
 
    
Scott Watermasysk (VIP)
Damian,

A couple suggestions:
1. Add a DB look up based on the directory. i.e., check for the name of the
directory (in this case briant) then you should be able to retrieve the ID.

2. Or, after you copy your templated pages to their new directory, use a
RegularExpression or String.Replace to "hard code" their id.

For example, in your template you might have this:
<personID:personBit id="personID" Person_id = "@@@" runat="server" />

All you would have to do, is do some kind of find and replace on "@@@" and
add "123".

HTH,
Scott

-----Original Message-----
From: Damian Barrow [mailto:Click here to reveal e-mail address]
Sent: Friday, June 14, 2002 9:15 AM
To: aspngreuse
Subject: [aspngreuse] Getting a value from an ascx

Hi all, this is probably easy but I just can't figure it out.

I have a person_info page, and all I do is copy a template page to a
directory in the name of the person (using FSO at the moment) so that they
can access their details by folder, rather than ID (eg
www.travelcounsellors.com/briant

The page is an ASPX and too complicated to muck about with, so I want an
ASCX in the same directory that I can simply say Person_id = 123, and then
use that id in the ASPX page to get all the details.

Can I do this (I could in an include I know) but I want to be able to later
on use richtextbox (www.richtextbox.com) to let the homeworkers do rich html
pages.

I'm looking for something like (in simple form):

ASPX:
<%@ Page Language="VB" %>
<%@ import Namespace="System.IO" %>
<%@ Register TagPrefix="personID" TagName="personBit" Src="/deleteme.ascx"
%> <personID:personBit id="personID" runat="server" />

<script runat="server">
lblPErsonID.Text = Person_id
</script>

<html>
<head>
</head>
<body>
<form runat="server">
<asp:Label id="lblPErsonID" runat="server">Label</asp:Label>
<!-- Insert content here -->
</form>
</body>
</html>

ASCX:
<%@ Control Language="VB" %>
<script runat="server">

Dim person_id as Integer
person_id = 717

</script>

Any help appreciated
Damian

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Damian Barrow
Hola Scott

1. That's a damn good idea as that information is already there.

2. I want it automated.

Can it be done though? Can I drag a value from an ascx and use it my
aspx page?

Damian

-----Original Message-----
From: Scott Watermasysk [mailto:Click here to reveal e-mail address]

Sent: 14 June 2002 16:14
To: aspngreuse
Subject: [aspngreuse] RE: Getting a value from an ascx

Damian,

A couple suggestions:
1. Add a DB look up based on the directory. i.e., check for the name of
the
directory (in this case briant) then you should be able to retrieve the
ID.

2. Or, after you copy your templated pages to their new directory, use a
RegularExpression or String.Replace to "hard code" their id.

For example, in your template you might have this:=20
<personID:personBit id=3D"personID" Person_id =3D "@@@" runat=3D"server" =
/>

All you would have to do, is do some kind of find and replace on "@@@"
and
add "123".

HTH,
Scott

-----Original Message-----
From: Damian Barrow [mailto:Click here to reveal e-mail address]=20
Sent: Friday, June 14, 2002 9:15 AM
To: aspngreuse
Subject: [aspngreuse] Getting a value from an ascx

Hi all, this is probably easy but I just can't figure it out.

I have a person_info page, and all I do is copy a template page to a
directory in the name of the person (using FSO at the moment) so that
they
can access their details by folder, rather than ID (eg
www.travelcounsellors.com/briant

The page is an ASPX and too complicated to muck about with, so I want an
ASCX in the same directory that I can simply say Person_id =3D 123, and
then
use that id in the ASPX page to get all the details.

Can I do this (I could in an include I know) but I want to be able to
later
on use richtextbox (www.richtextbox.com) to let the homeworkers do rich
html
pages.

I'm looking for something like (in simple form):

ASPX:
<%@ Page Language=3D"VB" %>
<%@ import Namespace=3D"System.IO" %>
<%@ Register TagPrefix=3D"personID" TagName=3D"personBit"
Src=3D"/deleteme.ascx"
%> <personID:personBit id=3D"personID" runat=3D"server" />

<script runat=3D"server">
lblPErsonID.Text =3D Person_id
</script>

<html>
<head>
</head>
<body>
<form runat=3D"server">
<asp:Label id=3D"lblPErsonID" runat=3D"server">Label</asp:Label>
<!-- Insert content here -->
</form>
</body>
</html>

ASCX:
<%@ Control Language=3D"VB" %>
<script runat=3D"server">

Dim person_id as Integer
person_id =3D 717

</script>

Any help appreciated
Damian

| [aspngreuse] member Click here to reveal e-mail address =3D YOUR =
ID=20
| http://www.aspfriends.com/aspfriends/aspngreuse.asp =3D JOIN/QUIT

| [aspngreuse] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp =3D JOIN/QUIT

_____________________________________________________________________
Travel Counsellors has scanned this message for all known viruses.

Reply to this message...
 
    
Scott Watermasysk (VIP)
Damian,

I am a little confused about what you are trying to do.

This is what I thought you were trying to.
1. A new user gets added to your system.
2. You then create a folder for the new person
3. You copy couple of prebuilt aspx/ascx files into the new directory?

Is this correct?

If so, what I suggested is when you copy the files, write some code that
reads the text from the copied files and inserts the person_id into a couple
of placeholders. (or do a db look up based on the directory...however, this
adds an extra db call to everytime the page is rendered).

And yes, you can get/set values in a user control from the page. Just mark
the methods as public (just like any other class).

HTH,
Scott

-----Original Message-----
From: Damian Barrow [mailto:Click here to reveal e-mail address]
Sent: Friday, June 14, 2002 10:52 AM
To: aspngreuse
Subject: [aspngreuse] RE: Getting a value from an ascx

Hola Scott

1. That's a damn good idea as that information is already there.

2. I want it automated.

Can it be done though? Can I drag a value from an ascx and use it my aspx
page?

Damian

-----Original Message-----
From: Scott Watermasysk [mailto:Click here to reveal e-mail address]

Sent: 14 June 2002 16:14
To: aspngreuse
Subject: [aspngreuse] RE: Getting a value from an ascx

Damian,

A couple suggestions:
1. Add a DB look up based on the directory. i.e., check for the name of the
directory (in this case briant) then you should be able to retrieve the ID.

2. Or, after you copy your templated pages to their new directory, use a
RegularExpression or String.Replace to "hard code" their id.

For example, in your template you might have this:
<personID:personBit id="personID" Person_id = "@@@" runat="server" />

All you would have to do, is do some kind of find and replace on "@@@" and
add "123".

HTH,
Scott

-----Original Message-----
From: Damian Barrow [mailto:Click here to reveal e-mail address]
Sent: Friday, June 14, 2002 9:15 AM
To: aspngreuse
Subject: [aspngreuse] Getting a value from an ascx

Hi all, this is probably easy but I just can't figure it out.

I have a person_info page, and all I do is copy a template page to a
directory in the name of the person (using FSO at the moment) so that they
can access their details by folder, rather than ID (eg
www.travelcounsellors.com/briant

The page is an ASPX and too complicated to muck about with, so I want an
ASCX in the same directory that I can simply say Person_id = 123, and then
use that id in the ASPX page to get all the details.

Can I do this (I could in an include I know) but I want to be able to later
on use richtextbox (www.richtextbox.com) to let the homeworkers do rich html
pages.

I'm looking for something like (in simple form):

ASPX:
<%@ Page Language="VB" %>
<%@ import Namespace="System.IO" %>
<%@ Register TagPrefix="personID" TagName="personBit" Src="/deleteme.ascx"
%> <personID:personBit id="personID" runat="server" />

<script runat="server">
lblPErsonID.Text = Person_id
</script>

<html>
<head>
</head>
<body>
<form runat="server">
<asp:Label id="lblPErsonID" runat="server">Label</asp:Label>
<!-- Insert content here -->
</form>
</body>
</html>

ASCX:
<%@ Control Language="VB" %>
<script runat="server">

Dim person_id as Integer
person_id = 717

</script>

Any help appreciated
Damian

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

_____________________________________________________________________
Travel Counsellors has scanned this message for all known viruses.

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Damian Barrow
Hi Scott. I've sussed it thanks to you.

I've just done as you suggested and it works great. What I wanted to do
was automate the process though - eg someone with no folder/default page
but a database entry can enter some details using richtextbox and then
hit save and have their directory created for them.

I can figure that bit out I think (or die trying).

The code you helped me with was:

<%@ Page Language=3D"vb" Explicit=3D"True" EnableSessionState=3D"True"
smartnavigation=3D"True" Trace=3D"true"%>
<%@ Import Namespace=3D"System.Text.RegularExpressions" %>
<script runat=3D"server">
Sub Page_Load(sender as Object, e as EventArgs)
     Dim folder_Name as String
             =20
     Dim Regexp as Regex =3D new
Regex("/default.aspx",RegexOptions.IgnoreCase)
                 folder_Name =3D
regexp.Replace(request.ServerVariables("PATH_INFO"),"")

    lblPath.Text =3D folder_Name

Using regex - is there a way I can also strip out the "/" as well? No
big deal, more of a learning curve thing.

Cheers
Damian

Reply to this message...
 
 
System.EventArgs
System.String
System.Text.RegularExpressions.Regex
System.Text.RegularExpressions.RegexOptions




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification