Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Monday, March 26, 2012

newbie and the /bin dir

Hi,

For a new ASP.Net application, I've read that it's dll's need to be stored
in the /bin dir which is created under the wwwroot/ directory.

I've also read that you can store dll's in a /bin dir under the application
itself e.g. wwwroot/myapp/bin.

I'm just trying to get to grips with the above...
- is the root /bin dir for dll's that are accessed by different web
applications?
- is the application /bin dir for dll's that are only accessed by the
application itself?

We have a few ASP apps on an ISP and are looking to xfer these to .Net. Is
is better to put our app dll's in the app /bin directory or risk class
compatibility problems by putting them in root/bin? Are there any security
problems or loss of performance putting them in an app dll?

Thanks for any advice given.

Best regards

Bob"Bob H" <bh15@.le.ac.uk> wrote in message
news:btbf8c$bin$1@.south.jnrs.ja.net...
> Hi,
> For a new ASP.Net application, I've read that it's dll's need to be stored
> in the /bin dir which is created under the wwwroot/ directory.
> I've also read that you can store dll's in a /bin dir under the
application
> itself e.g. wwwroot/myapp/bin.
> I'm just trying to get to grips with the above...
> - is the root /bin dir for dll's that are accessed by different web
> applications?
> - is the application /bin dir for dll's that are only accessed by the
> application itself?
> We have a few ASP apps on an ISP and are looking to xfer these to .Net. Is
> is better to put our app dll's in the app /bin directory or risk class
> compatibility problems by putting them in root/bin? Are there any security
> problems or loss of performance putting them in an app dll?
> Thanks for any advice given.
> Best regards
> Bob

When you use Visual Studio to build your ASP.Net application, that will
compile
your application into dll's and place them in your application-bin
directory.

Using Visual Studio, you need to "reference" your COM-dll's. Those com-dll's
need to be registered as usual. A .Net interface is automatically generated.

Hans Kesting
Hi bob,

to understand this, you need to understand a bit about IIS web applications,
and how they are configured, in particular, ASP.Net applications.

In IIS, a web application is configured in the metabase. A web application
is a distinct memory space which is used by all server-side entities
belonging to a web application. A web application is defined by a set of
folders and files that reside under the "root" folder of the application. If
a sub-folder of an application root folder is configured as a web
application, it has its own separate memory space for all folders underneath
it. Therefore, you can have nested web applications, one inside another
physically (in the folder structure) but having a completely separate memory
space.

In ASP.Net, there are certain special files and folders which relate to the
web application. One of these is the bin folder. The bin folder must reside
directly underneath the application root folder. This is how ASP.Net apps
find the DLLs that you store there. You can tweak the location of these DLLs
in the configuration files if you need to, but usually you don't, and you
should store your DLLs in the bin folder directly under the root. In
addition, the web.config and global.asax files for each application must
reside in the root folder of that application.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Bob H" <bh15@.le.ac.uk> wrote in message
news:btbf8c$bin$1@.south.jnrs.ja.net...
> Hi,
> For a new ASP.Net application, I've read that it's dll's need to be stored
> in the /bin dir which is created under the wwwroot/ directory.
> I've also read that you can store dll's in a /bin dir under the
application
> itself e.g. wwwroot/myapp/bin.
> I'm just trying to get to grips with the above...
> - is the root /bin dir for dll's that are accessed by different web
> applications?
> - is the application /bin dir for dll's that are only accessed by the
> application itself?
> We have a few ASP apps on an ISP and are looking to xfer these to .Net. Is
> is better to put our app dll's in the app /bin directory or risk class
> compatibility problems by putting them in root/bin? Are there any security
> problems or loss of performance putting them in an app dll?
> Thanks for any advice given.
> Best regards
> Bob
Hi,
I'm also a newbie in ASP.NET. I'm wondering if the bin dir for the dll
is neccessary or if there is a possibility to store the dll of the web
application at an other place. E.g. in the application root.

Can anyone please tell me whether this is possible and if not why not.
Perhaps someone of you also know a link to the specification of
ASP.NET where that things a described.

Thanks In Advance

Markus Heid

"Kevin Spencer" <kevin@.takempis.com> wrote in message news:<eV27qn60DHA.4032@.tk2msftngp13.phx.gbl>...
> Hi bob,
> to understand this, you need to understand a bit about IIS web applications,
> and how they are configured, in particular, ASP.Net applications.
> In IIS, a web application is configured in the metabase. A web application
> is a distinct memory space which is used by all server-side entities
> belonging to a web application. A web application is defined by a set of
> folders and files that reside under the "root" folder of the application. If
> a sub-folder of an application root folder is configured as a web
> application, it has its own separate memory space for all folders underneath
> it. Therefore, you can have nested web applications, one inside another
> physically (in the folder structure) but having a completely separate memory
> space.
> In ASP.Net, there are certain special files and folders which relate to the
> web application. One of these is the bin folder. The bin folder must reside
> directly underneath the application root folder. This is how ASP.Net apps
> find the DLLs that you store there. You can tweak the location of these DLLs
> in the configuration files if you need to, but usually you don't, and you
> should store your DLLs in the bin folder directly under the root. In
> addition, the web.config and global.asax files for each application must
> reside in the root folder of that application.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.

newbie asp.net project question...

I have a simple question. I created a new Web thru IIS (MyWeb) that points to c:\Inetpub\wwwroot\MyWeb
Then I created a new asp.net project in VS. The problem that I have is this: when I compile and run the project, it's link looks like this

http://localhost/MyWeb/Default.asp

which means that if in Default.aspx I put a link to "\login.aspx" for example, it will fail, because "\" is "/localhost/". I need to have the root represented by the entire link. Therefore "\login.aspx" should point to "http://localhost/MyWeb/login.aspx" instead of "http://localhost/login.aspx". If it doesnt how am I supposed to work on different projects?? If I need to work on 3 different sites I need each of them to have it's own root..

How can I do that? Thank you

andrewHey Andrew,

Are you talking about Server.MapPath??

Jodie Rapson

"Andrew Parks" <anonymous@.discussions.microsoft.com> wrote in message
news:FA3EFDD8-EBE2-400F-BA8B-DD9BFF40AB64@.microsoft.com...
> I have a simple question. I created a new Web thru IIS (MyWeb) that points
to c:\Inetpub\wwwroot\MyWeb.
> Then I created a new asp.net project in VS. The problem that I have is
this: when I compile and run the project, it's link looks like this:
> http://localhost/MyWeb/Default.aspx
> which means that if in Default.aspx I put a link to "\login.aspx" for
example, it will fail, because "\" is "/localhost/". I need to have the root
represented by the entire link. Therefore "\login.aspx" should point to
"http://localhost/MyWeb/login.aspx" instead of
"http://localhost/login.aspx". If it doesnt how am I supposed to work on
different projects?? If I need to work on 3 different sites I need each of
them to have it's own root...
> How can I do that? Thank you!
> andrew
No, what I mean is, on my development machine the projects are arranged like this

http://localhost/MyWeb1/ (MyWeb1 is the virtual dir setup in IIS
http://localhost/MyWeb2/ (MyWeb2 is the virtual dir setup in IIS

So, to refer a file

http://localhost/MyWeb1/Default.asp

When I deploy the finalized web application on the web it will be something like this

http://some.server.com/Default.asp

If I put a link in Default.aspx that reads: href="http://links.10026.com/?link=\Login.aspx", it will work on the deployed version, as

http://some.server.com/Login.asp

exists, but on the development machine it will not work because it will point to

http://localhost/Login.aspx, instead of http//localhost/MyWeb1/Login.asp

This means that either I have to deploy it as http://some.server.com/MyWeb1/ (which is not cool at all) or I have to work with ALL my projects directly in the root, which again is not good..

How can I do this
than
What are you using to develop? As using "/file.aspx" should work on both

server and dev machine.

Jodie Rapson

"Andrew Parks" <anonymous@.discussions.microsoft.com> wrote in message
news:FA3EFDD8-EBE2-400F-BA8B-DD9BFF40AB64@.microsoft.com...
> I have a simple question. I created a new Web thru IIS (MyWeb) that points
to c:\Inetpub\wwwroot\MyWeb.
> Then I created a new asp.net project in VS. The problem that I have is
this: when I compile and run the project, it's link looks like this:
> http://localhost/MyWeb/Default.aspx
> which means that if in Default.aspx I put a link to "\login.aspx" for
example, it will fail, because "\" is "/localhost/". I need to have the root
represented by the entire link. Therefore "\login.aspx" should point to
"http://localhost/MyWeb/login.aspx" instead of
"http://localhost/login.aspx". If it doesnt how am I supposed to work on
different projects?? If I need to work on 3 different sites I need each of
them to have it's own root...
> How can I do that? Thank you!
> andrew
I use VS2003 and Framework 1.1.

It doesn't work as you say. For instance if I have an image href = "\Images\image1.gif

If I place the file here: c:\Inetpub\wwwroot\MyWeb\Images\image1.gif, it doesnt work. But if I put it here

c:\Inetpub\wwwroot\Images\image1.gif it works.

This is all on the dev machine. This means that "\" = "c:\Inetpub\wwwroot" when I really need it to be "c:\Inetpub\wwwroot\MyWeb". However, after researching a little bit on the web it looks like what I want is not possible. This means that I can only work on 1 project at a time or combine ALL projects in "c:\Inetpub\wwwroot"...

:-
What are you using to dev? As I have been doing this for a few years and

this "/page.aspx" should be fine for test and server.

Jodie

"Andrew" <anonymous@.discussions.microsoft.com> wrote in message
news:2DE4C85F-943B-4499-A145-70FE856DE815@.microsoft.com...
> No, what I mean is, on my development machine the projects are arranged
like this:
> http://localhost/MyWeb1/ (MyWeb1 is the virtual dir setup in IIS)
> http://localhost/MyWeb2/ (MyWeb2 is the virtual dir setup in IIS)
> So, to refer a file:
> http://localhost/MyWeb1/Default.aspx
> When I deploy the finalized web application on the web it will be
something like this:
> http://some.server.com/Default.aspx
> If I put a link in Default.aspx that reads: href="http://links.10026.com/?link=\Login.aspx", it will
work on the deployed version, as:
> http://some.server.com/Login.aspx
> exists, but on the development machine it will not work because it will
point to:
> http://localhost/Login.aspx, instead of http//localhost/MyWeb1/Login.aspx
> This means that either I have to deploy it as
http://some.server.com/MyWeb1/ (which is not cool at all) or I have to work
with ALL my projects directly in the root, which again is not good...
> How can I do this?
> thanx

newbie asp.net user control question

Hi, I created a user control within my asp.net application. It has
an .ascx extension. I use this control many times within this
application and it works fine. I wrote this user control to be
generic though, because I want it to be accessible from other asp.net
applications as well. How do I break out the user control into a
seperate dll that can be references by many asp.net apps? I fooled
around with the "Web Control Library" but I must be doing something
wrong because it doesn't seem right. For instance it is listing a
"Windows Forms" section on the toolbox rather than the "Web Forms"
section that I need. Also there is no html section on the designer.
I must have gone off track somewhere... Any help you can provide
would be greatly appreciated. Thanks!On Jun 27, 10:55 pm, mbosc...@.hotmail.com wrote:
> Hi, I created a user control within my asp.net application. It has
> an .ascx extension. I use this control many times within this
> application and it works fine. I wrote this user control to be
> generic though, because I want it to be accessible from other asp.net
> applications as well. How do I break out the user control into a
> seperate dll that can be references by many asp.net apps? I fooled
> around with the "Web Control Library" but I must be doing something
> wrong because it doesn't seem right. For instance it is listing a
> "Windows Forms" section on the toolbox rather than the "Web Forms"
> section that I need. Also there is no html section on the designer.
> I must have gone off track somewhere... Any help you can provide
> would be greatly appreciated. Thanks!
hi... :)
If you want to use your control in multiple projects and you actually
want made it generic enough you have to write a custom control... okay
that good... now you can still use user user control in multiple
project but for this you got to copy the ascx file and its cs file to
the new project...
Thanks
Masudur
http://www.kaz.com.bd
http://munnacs.110mb.com

newbie asp.net user control question

Hi, I created a user control within my asp.net application. It has
an .ascx extension. I use this control many times within this
application and it works fine. I wrote this user control to be
generic though, because I want it to be accessible from other asp.net
applications as well. How do I break out the user control into a
seperate dll that can be references by many asp.net apps? I fooled
around with the "Web Control Library" but I must be doing something
wrong because it doesn't seem right. For instance it is listing a
"Windows Forms" section on the toolbox rather than the "Web Forms"
section that I need. Also there is no html section on the designer.
I must have gone off track somewhere... Any help you can provide
would be greatly appreciated. Thanks!On Jun 27, 10:55 pm, mbosc...@.hotmail.com wrote:

Quote:

Originally Posted by

Hi, I created a user control within my asp.net application. It has
an .ascx extension. I use this control many times within this
application and it works fine. I wrote this user control to be
generic though, because I want it to be accessible from other asp.net
applications as well. How do I break out the user control into a
seperate dll that can be references by many asp.net apps? I fooled
around with the "Web Control Library" but I must be doing something
wrong because it doesn't seem right. For instance it is listing a
"Windows Forms" section on the toolbox rather than the "Web Forms"
section that I need. Also there is no html section on the designer.
I must have gone off track somewhere... Any help you can provide
would be greatly appreciated. Thanks!


hi... :)

If you want to use your control in multiple projects and you actually
want made it generic enough you have to write a custom control... okay
that good... now you can still use user user control in multiple
project but for this you got to copy the ascx file and its cs file to
the new project...

Thanks
Masudur
http://www.kaz.com.bd
http://munnacs.110mb.com

Saturday, March 24, 2012

Newbie Help (Parser Error)

I just created a test asp.net application using VB.net. I have DotNetFramework 1.1 installed.

The default.aspx page simply displays a form and a heading:

PAGE CODE:
------
<%@dotnet.itags.org. Page Language="VB" %>
<html>
<body>
<form id='form1' method='post' runat='server'>
<h1> Welcome to First Application</h1>
<asp:button id='btnNavigate' runat='server' text='Navigate'/>
</form>
</body>
</html
--------

When I run the application I get the following error.

ERROR MESSAGE:
--------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'firstapp.Global'.

Source Error:

Line 1: <%@dotnet.itags.org. Application Codebehind="Global.asax.vb" Inherits="firstapp.Global" %
Source File: c:\inetpub\wwwroot\firstapp\global.asax Line: 1

-------------------

I am not sure why. The application was install as an asp.net application on IIS 5.

Any help would be greatly appreciated. My email is tcornett@dotnet.itags.org.ci.kingman.az.us

Thanks,

Terry C.There are several files required for an ASP.NET web app:
1. Your web form(s)
2. The web.config file
3. The Global.asax file

The Global.asax file must define a class called Global, subclassed from httpApplication. It appears that you have defined a Global.asax file and it refers to a code behind file that should define that Global class. Most likely, you have not compiled the file Global.asax.vb into an assembly that is part of your \bin folder. (All .vb files can be compiled into one single assembly. If you are using Visual Studio.net, that should happen automatically, assembling Global.asax is in your solution and it's Build Action property is set to "Compile".)
Thanks Peter.

I did not realize I had to build the solution for such a simple test web application. The book I was using as a reference did not mention that.

Once I built the solution it worked.

Thanks again for the help.

Terry C. :-)

Thursday, March 22, 2012

Newbie mistake or Custom Validator bug?

I have a very strange problem involving controls and the CustomValidator.

We have created a custom control. The control includes an ordinary textbox,
a customvalidator with the ControlToValidate set to the textbox, and a
VBScript validator subroutine. The purpose of the sub is to insure that only
dates that fall on Monday are permitted. The custom validator is exposed
through a property to permit enabling and disabling as needed.

The problem is this. If I have two instances of the control on a page, the
custom validator of the first instance is apparently calling the sub of the
second. The net effect is that I cannot properly validate Mondays on the
first control. This control seems to work fine when there is only one
instance on a page. When I examine the HTML source, it appears that there
are the correct instances of the code, each accessing the correct controls.

(I should admit upfront that the control also contains a ThirdParty calendar
date selector, Telerik, but as far as I can tell, none of the problem code
interacts with it in any way. It's sole purpose is to put a property
formatted date string into the textbox.)Please post:
1. The ASP.NET definitions of the controls involved.
2. The server side code involved.
3. The client-side code involved.

-- Peter Blum
www.PeterBlum.com
Email: PLBlum@.PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"B. Chernick" <BChernick@.discussions.microsoft.com> wrote in message
news:4AC9AE8B-E970-4340-AAD3-EB49500ED8A0@.microsoft.com...
>I have a very strange problem involving controls and the CustomValidator.
> We have created a custom control. The control includes an ordinary
> textbox,
> a customvalidator with the ControlToValidate set to the textbox, and a
> VBScript validator subroutine. The purpose of the sub is to insure that
> only
> dates that fall on Monday are permitted. The custom validator is exposed
> through a property to permit enabling and disabling as needed.
> The problem is this. If I have two instances of the control on a page,
> the
> custom validator of the first instance is apparently calling the sub of
> the
> second. The net effect is that I cannot properly validate Mondays on the
> first control. This control seems to work fine when there is only one
> instance on a page. When I examine the HTML source, it appears that there
> are the correct instances of the code, each accessing the correct
> controls.
> (I should admit upfront that the control also contains a ThirdParty
> calendar
> date selector, Telerik, but as far as I can tell, none of the problem code
> interacts with it in any way. It's sole purpose is to put a property
> formatted date string into the textbox.)
I have just created a test case (without any 3rd party controls,
incidentally. That appears to have nothing to do with the problem)

First create a user control with a textbox and a custom validator:
-- ASPX starts here -----
<%@. Control Language="vb" AutoEventWireup="false"
Codebehind="CalendarTest.ascx.vb" Inherits="test1.CalendarTest"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<asp:TextBox id="txtDate" runat="server" Columns="18"
CssClass="text"></asp:TextBox>
<asp:CustomValidator id="MondayValidator1" runat="server"
ClientValidationFunction="ValidateMondayVB"
ErrorMessage="The Date is not a Monday" Enabled="False"
ControlToValidate="txtDate">*</asp:CustomValidator>
<script language="vbscript"
Sub ValidateMondayVB(source, args)

If IsDate(document.forms("Form1").item("<%= Me.txtDate.ClientID
%>").Value) then

startDt = CDate(document.forms("Form1").item("<%= Me.txtDate.ClientID
%>").Value)
msgbox "Here I am control <%= Me.ClientID %>, box = <%=
Me.txtDate.ClientID %> , source.id = " & source.id
If WeekDay(startDt) <> vbMonday then
msgbox "Start date must be a Monday. You specified a " &
WeekdayName(WeekDay(startDt)) & "."
args.IsValid = false
Else
args.IsValid = true
End if

End if

End Sub
</script
--- ASPX ends here ----
Next add the following property to the control code behind:
Public Property MondayValidator() As CustomValidator
Get
Return MondayValidator1
End Get
Set(ByVal Value As CustomValidator)
MondayValidator1 = Value
End Set
End Property
---
Now create a test page using the control:

--- test page ASPX starts here ----------

<%@. Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm12.aspx.vb" Inherits="test1.WebForm12"%>
<%@. Register TagPrefix="uc1" TagName="CalendarTest" src="http://pics.10026.com/?src=CalendarTest.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm12</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:ValidationSummary id="ValidationSummary1" runat="server"
BorderStyle="Outset" Width="272px"></asp:ValidationSummary>
<P>
<uc1:CalendarTest id="CalendarTest1"
runat="server"></uc1:CalendarTest>
<uc1:CalendarTest id="CalendarTest2"
runat="server"></uc1:CalendarTest></P>
<P> </P>
<P>
<asp:Button id="Button1" runat="server" Text="Validate"></asp:Button></P>
</form>
</body>
</HTML>
--- test page ASPX ends here -------

Finally add the following to the test page's Page_Load

CalendarTest1.MondayValidator.Enabled = True
CalendarTest1.MondayValidator.ErrorMessage = "Test1 Fired"
CalendarTest2.MondayValidator.Enabled = False
CalendarTest2.MondayValidator.ErrorMessage = "Test2 Fired"

Now run the project. Enter a Monday date (2/20/2006 for example) in the
first box. Enter a non-Monday date in the second. (In my actual work, these
boxes would have Javascript formatting routines forcing a mm/dd/yyyy format
so only use that.) Now press the button. The first validator fires after
apparently using the 2nd instances VBscript sub, or so it looks to me.

Thanks

"Peter Blum" wrote:

> Please post:
> 1. The ASP.NET definitions of the controls involved.
> 2. The server side code involved.
> 3. The client-side code involved.
> -- Peter Blum
> www.PeterBlum.com
> Email: PLBlum@.PeterBlum.com
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
> "B. Chernick" <BChernick@.discussions.microsoft.com> wrote in message
> news:4AC9AE8B-E970-4340-AAD3-EB49500ED8A0@.microsoft.com...
> >I have a very strange problem involving controls and the CustomValidator.
> > We have created a custom control. The control includes an ordinary
> > textbox,
> > a customvalidator with the ControlToValidate set to the textbox, and a
> > VBScript validator subroutine. The purpose of the sub is to insure that
> > only
> > dates that fall on Monday are permitted. The custom validator is exposed
> > through a property to permit enabling and disabling as needed.
> > The problem is this. If I have two instances of the control on a page,
> > the
> > custom validator of the first instance is apparently calling the sub of
> > the
> > second. The net effect is that I cannot properly validate Mondays on the
> > first control. This control seems to work fine when there is only one
> > instance on a page. When I examine the HTML source, it appears that there
> > are the correct instances of the code, each accessing the correct
> > controls.
> > (I should admit upfront that the control also contains a ThirdParty
> > calendar
> > date selector, Telerik, but as far as I can tell, none of the problem code
> > interacts with it in any way. It's sole purpose is to put a property
> > formatted date string into the textbox.)
>

Newbie mistake or Custom Validator bug?

I have a very strange problem involving controls and the CustomValidator.
We have created a custom control. The control includes an ordinary textbox,
a customvalidator with the ControlToValidate set to the textbox, and a
VBScript validator subroutine. The purpose of the sub is to insure that onl
y
dates that fall on Monday are permitted. The custom validator is exposed
through a property to permit enabling and disabling as needed.
The problem is this. If I have two instances of the control on a page, the
custom validator of the first instance is apparently calling the sub of the
second. The net effect is that I cannot properly validate Mondays on the
first control. This control seems to work fine when there is only one
instance on a page. When I examine the HTML source, it appears that there
are the correct instances of the code, each accessing the correct controls.
(I should admit upfront that the control also contains a ThirdParty calendar
date selector, Telerik, but as far as I can tell, none of the problem code
interacts with it in any way. It's sole purpose is to put a property
formatted date string into the textbox.)Please post:
1. The ASP.NET definitions of the controls involved.
2. The server side code involved.
3. The client-side code involved.
-- Peter Blum
www.PeterBlum.com
Email: PLBlum@.PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"B. Chernick" <BChernick@.discussions.microsoft.com> wrote in message
news:4AC9AE8B-E970-4340-AAD3-EB49500ED8A0@.microsoft.com...
>I have a very strange problem involving controls and the CustomValidator.
> We have created a custom control. The control includes an ordinary
> textbox,
> a customvalidator with the ControlToValidate set to the textbox, and a
> VBScript validator subroutine. The purpose of the sub is to insure that
> only
> dates that fall on Monday are permitted. The custom validator is exposed
> through a property to permit enabling and disabling as needed.
> The problem is this. If I have two instances of the control on a page,
> the
> custom validator of the first instance is apparently calling the sub of
> the
> second. The net effect is that I cannot properly validate Mondays on the
> first control. This control seems to work fine when there is only one
> instance on a page. When I examine the HTML source, it appears that there
> are the correct instances of the code, each accessing the correct
> controls.
> (I should admit upfront that the control also contains a ThirdParty
> calendar
> date selector, Telerik, but as far as I can tell, none of the problem code
> interacts with it in any way. It's sole purpose is to put a property
> formatted date string into the textbox.)
>
I have just created a test case (without any 3rd party controls,
incidentally. That appears to have nothing to do with the problem)
First create a user control with a textbox and a custom validator:
-- ASPX starts here --
<%@. Control Language="vb" AutoEventWireup="false"
Codebehind="CalendarTest.ascx.vb" Inherits="test1.CalendarTest"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<asp:TextBox id="txtDate" runat="server" Columns="18"
CssClass="text"></asp:TextBox>
<asp:CustomValidator id="MondayValidator1" runat="server"
ClientValidationFunction="ValidateMondayVB"
ErrorMessage="The Date is not a Monday" Enabled="False"
ControlToValidate="txtDate">*</asp:CustomValidator>
<script language="vbscript">
Sub ValidateMondayVB(source, args)
If IsDate(document.forms("Form1").item("<%= Me.txtDate.ClientID
%>").Value) then
startDt = CDate(document.forms("Form1").item("<%= Me.txtDate.ClientID
%>").Value)
msgbox "Here I am control <%= Me.ClientID %>, box = <%=
Me.txtDate.ClientID %> , source.id = " & source.id
If WDay(startDt) <> vbMonday then
msgbox "Start date must be a Monday. You specified a " &
WdayName(WDay(startDt)) & "."
args.IsValid = false
Else
args.IsValid = true
End if
End if
End Sub
</script>
-- ASPX ends here --
Next add the following property to the control code behind:
Public Property MondayValidator() As CustomValidator
Get
Return MondayValidator1
End Get
Set(ByVal Value As CustomValidator)
MondayValidator1 = Value
End Set
End Property
--
Now create a test page using the control:
-- test page ASPX starts here --
<%@. Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm12.aspx.vb" Inherits="test1.WebForm12"%>
<%@. Register TagPrefix="uc1" TagName="CalendarTest" src="http://pics.10026.com/?src=CalendarTest.ascx"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm12</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:ValidationSummary id="ValidationSummary1" runat="server"
BorderStyle="Outset" Width="272px"></asp:ValidationSummary>
<P>
<uc1:CalendarTest id="CalendarTest1"
runat="server"></uc1:CalendarTest>
<uc1:CalendarTest id="CalendarTest2"
runat="server"></uc1:CalendarTest></P>
<P> </P>
<P>
<asp:Button id="Button1" runat="server" Text="Validate"></asp:Button></P>
</form>
</body>
</HTML>
-- test page ASPX ends here --
Finally add the following to the test page's Page_Load
CalendarTest1.MondayValidator.Enabled = True
CalendarTest1.MondayValidator.ErrorMessage = "Test1 Fired"
CalendarTest2.MondayValidator.Enabled = False
CalendarTest2.MondayValidator.ErrorMessage = "Test2 Fired"
Now run the project. Enter a Monday date (2/20/2006 for example) in the
first box. Enter a non-Monday date in the second. (In my actual work, thes
e
boxes would have Javascript formatting routines forcing a mm/dd/yyyy format
so only use that.) Now press the button. The first validator fires after
apparently using the 2nd instances VBscript sub, or so it looks to me.
Thanks
"Peter Blum" wrote:

> Please post:
> 1. The ASP.NET definitions of the controls involved.
> 2. The server side code involved.
> 3. The client-side code involved.
> -- Peter Blum
> www.PeterBlum.com
> Email: PLBlum@.PeterBlum.com
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
> "B. Chernick" <BChernick@.discussions.microsoft.com> wrote in message
> news:4AC9AE8B-E970-4340-AAD3-EB49500ED8A0@.microsoft.com...
>
>

Friday, March 16, 2012

Newbie needs help with user controls

I created a menu that I want on every page and saved it as a .ascx file. It works on my web site, but when I'm testing scripts on my local machine using IIS, the menu will not show up.

I do not get an error or anything, but was hoping someone could point me in the right direction. Is there a setting in IIS or WebMatrix that is causing the menu not to show up and I need to change?

Thanx in advance!Can u post your code please.
Menu.ascx
===================================================

<%@. Control Language="VB" %>
Members | Sign
Up | News | Forums | Mobile | Tutorials | Resources | Support | Search
===================================================

Default.aspx
===================================================

<%@. Page Language="VB" Debug="true" %>
<%@. Register TagPrefix="dotnet" TagName="mnDotnet" src="http://pics.10026.com/?src=Menu.ascx" %>
<html>
<head>
<title>Yourdotnet.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="http://links.10026.com/?link=css/dotnet.css" type="text/css" rel="stylesheet" />
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<!-- Start Main table -->
<table cellspacing="0" cellpadding="0" width="760" border="0">
<tbody>
<tr>
<td>
<!-- Begin Header table -->
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td class="text3" valign="center" background="images/bg_grey3D.gif" widht="625">
<!-- Begin User Control for the menu -->
<dotnet:mnDotnet id="mnDotnet" runat="server"></dotnet:mnDotnet>
</td>
<td valign="center" align="right" width="135" background="images/bg_grey3D.gif">
<img src="http://pics.10026.com/?src=images/logo_dotnet.gif" width="135" border="0" /></td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</tbody>
</table>
<!-- End Header table --></td>
</tr>
<tr>
<td valign="top">
<!-- Start Main Content table -->
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td class="border" valign="top" align="middle" width="180">
<br />
<!-- Start Web Hosting Etc Banner -->
<hr width="100%" color="#c5c5c5" noshade="noshade" size="1" />
<img src="http://pics.10026.com/?src=http://www.webhostingetc.net/ads/renderbanners/smallsquare.jpg" border="0" />
<hr width="100%" color="#c5c5c5" noshade="noshade" size="1" />
<img alt="Powered by ASP.NET" src="http://pics.10026.com/?src=images/logo_aspdotnet.gif" border="0" />
<br />
<br />
</td>
<td class="border">
<table cellpadding="4" align="center" border="0">
<tbody>
<tr>
<td align="middle">
</td>
</tr>
<tr>
<td>
<p align="center">
<b class="headline">This site is under construction...Please check back soon!</b>
</p>
<br />
<form runat="server">
</form>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- End Main Content table --></td>
</tr>
<tr>
<td align="middle">

</td>
</tr>
</tbody>
</table>
<!-- End Main table -->
</body>
</html>
====================================================

Thanks midi25
Theres alot of code there my brother and looks in need of a clean up. I suspect and this has happened to me a few times that the html comments or a faulty <tag> somewhere may be giving you a problem and not causing the control to be displayed. Apart from that the rest of the .net code looks ok. Also make sure that default.aspx and menu.ascx are both in your root folder in IIS.
Thanx for the reply. I think you might have found the problem since I have the 2 files in a folder, named 'dotnet' which is a folder in the root directory of my IIS. The only reason I put them there was because I was planning on developing an intranet for my home network and assumed that I could not have both in the IIS root folder.

This leads me to my next question (and then I'll stop bothering you). If I do develop an intranet and put the 2 forementioned files in the root folder, how will users get to each site since they will both have a default.aspx file in the same directory?

Do I need to:

1. assign each site its own server port OR

2. just create the intranet and put the 'dotnet' directory as a sub-directory in that? If so, won't I encounter the same problem, because I will then need 2 menu.ascx files, 1 for the intranet and for dotnet site?
Note: the intranet site will be something completely different than the dotnet site, which is merely for testing scripts before uploading them to my web host, so I really do not want to keep them in the same directory.

Last question:

Could you please recommend a good .NET web host(s)?

Newbie needs some hand holding - dont know where to put the code.

Hi all. I have never created anything in ASP.NET but over the past week I've been trawling the web for some answer and I'm struggling.

What i need is an aspx page that I can call from flash parsing the a ID to my sql statement and it returns me the data to display in Flash.

So far what I've managed to achieve is the following.

1. i create a new web site. I've managed to get it all up and running in IIS and it connects to the MsSQL Database. I'm using 2005 and VB script. I can get my values to display in a Grid view but what i need it to do is execute a function on page load. Now someone told me put the code in code behind but I have no idea what that means.

the code i got from a tutorial is as follows:

Private Function GetXML(ByVal SQLCom As SQLCommand, ByVal TableName As String) As XMLDocument

Dim Temp As New XmlDocument()

With SQLCom

.Connection.Open()

Dim i As Integer

Dim SQLData As SqlDataReader = .ExecuteReader

With SQLData

Temp.AppendChild(Temp.CreateElement(TableName))

While .Read

Temp.FirstChild.AppendChild(Temp.CreateElement("item"))

For i = 0 To .FieldCount - 1

Temp.FirstChild.LastChild.Attributes.Append(Temp.CreateAttribute(.GetName(i))).Value = .GetValue(i)

Next

End While

End With

.Connection.Close()

End With

Return Temp

End Function

Response.ContentType = "text/xml"

GetData(SQLProductsGet, "products").Save(Response.OutputStream)

My first problem, i don't know how or where to put this code. I'm supposed to be able to call the getXML function in flash.

Secondly, does this code return an xml file?

if anyone can help or suggest an alternative solution I'd be most grateful.

Many thanks.

blu.

Hello my friend,

Yes the output of this page will be an xml file, courtesy of the "Response.ContentType = "text/xml" line.

To put this code into your aspx page you have 2 choices. If your aspx page has a code-behind file you can put it in there. In asp.net, you can code aspx pages primarily in either VB.NET or c#. If you are coding them in VB.NET, your pages may have vb code behind files. Default.aspx will have another file called Default.aspx.vb, Hello.aspx will have a file called Hello.aspx.vb. If coding in C#, they will have cs instead of vb. The code you have is in VB.NET.

But you do not need to put the code in a code behind. You can instead put it into the actual aspx page that contains the html via the script tag. I give an example page below: -

<%@. Page Language="VB" AutoEventWireup="true" CodeFile="TestPage.aspx.vb" Inherits="TestPage" %>

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

<script runat="server">

' paste code in here

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

Kind regards

Scotty


hi scotty thank for your response.

Still no joy though :-(

i created a new Web form page - then put this code in... (there isn't a aspx.vb file that was created - to i need to manually create one)

<%@.PageLanguage="VB"AutoEventWireup="true"CodeFile="careers.aspx.vb"Inherits="careers" %>

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

<scriptrunat="server">

PrivateFunction GetXML(ByVal SQLComAs SQLCommand,ByVal TableNameAsString)As XMLDocument

Dim TempAsNew XmlDocument()

With SQLCom

.Connection.Open()

Dim iAsInteger

Dim SQLDataAs SqlDataReader = .ExecuteReaderWith SQLData

Temp.AppendChild(Temp.CreateElement(TableName))

While .Read

Temp.FirstChild.AppendChild(Temp.CreateElement("item"))For i = 0To .FieldCount - 1

Temp.FirstChild.LastChild.Attributes.Append(Temp.CreateAttribute(.GetName(i))).Value = .GetValue(i)

Next

EndWhile

EndWith

.Connection.Close()

EndWith

Return Temp

EndFunction

Response.ContentType ="text/xml"

GetData(SQLProductsGet,"careers").Save(Response.OutputStream)

</script>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

</div>

</form>

</body>

</html>

i get a whole bunch of errors that I'd appreciate some help with

Validation(): Element 'html' occurs too few times

'Context is not a member of careers (Careers is my page name

Class connectors_careers.aspx must implement REadOnlyPropery is Reusable() ...

... must implement Sub ProcessRequest for interface System.WebIHttpHandler

GetWrappedFileDependecies is not a member of ASPConnectors_careers.aspx

sub processRequest cannot be declared 'Overrides' because it does not overide a sub in a base class.

process request is not a member of careers

there's a whole bunch of others bt i'm guessing they're related.

also some Declaration expected errors.

do i need to import something (as i would in java)?

thanks scotty


hi scotty thank for your response.

Still no joy though :-(

i created a new Web form page - then put this code in... (there isn't a aspx.vb file that was created - to i need to manually create one)

<%@.PageLanguage="VB"AutoEventWireup="true"CodeFile="careers.aspx.vb"Inherits="careers" %>

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

<scriptrunat="server">

PrivateFunction GetXML(ByVal SQLComAs SQLCommand,ByVal TableNameAsString)As XMLDocument

Dim TempAsNew XmlDocument()

With SQLCom

.Connection.Open()

Dim iAsInteger

Dim SQLDataAs SqlDataReader = .ExecuteReaderWith SQLData

Temp.AppendChild(Temp.CreateElement(TableName))

While .Read

Temp.FirstChild.AppendChild(Temp.CreateElement("item"))For i = 0To .FieldCount - 1

Temp.FirstChild.LastChild.Attributes.Append(Temp.CreateAttribute(.GetName(i))).Value = .GetValue(i)

Next

EndWhile

EndWith

.Connection.Close()

EndWith

Return Temp

EndFunction

Response.ContentType ="text/xml"

GetData(SQLProductsGet,"careers").Save(Response.OutputStream)

</script> <htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Untitled Page</title> </head>

<body>

<formid="form1"runat="server">

<div>

</div>

</form> </body>

</html>

i get a whole bunch of errors that I'd appreciate some help with

Validation(): Element 'html' occurs too few times

'Context is not a member of careers (Careers is my page name

Class connectors_careers.aspx must implement REadOnlyPropery is Reusable() ...

... must implement Sub ProcessRequest for interface System.WebIHttpHandler

GetWrappedFileDependecies is not a member of ASPConnectors_careers.aspx

sub processRequest cannot be declared 'Overrides' because it does not overide a sub in a base class.

process request is not a member of careers

there's a whole bunch of others bt i'm guessing they're related.

also some Declaration expected errors.

do i need to import something (as i would in java)?

thanks scotty


sorry pressed enter too many times there. just want to say i noticed that its now created an aspx.vb file - also this tutorial is asp.net 1.0 how would it be different for asp.net 2.0?