Showing posts with label controls. Show all posts
Showing posts with label controls. Show all posts

Monday, March 26, 2012

newbie 101

NT2003, .Net 2 - ran the test for it, too... just to be sure

none of the serious .net controls work... try on different machines.. same... but the calendar works

none of the samples work from the book... all the same type of error

<please help before I toss all this and go back to CLIPPER>

Parser Error

Description:Anerror occurred during the parsing of a resource required to servicethis request. Please review the following specific parse error detailsand modify your source file appropriately.

Parser Error Message:Couldnot load type System.Web.UI.WebControls.TreeViewTreeView from assemblySystem.Web, Version=1.0.5000.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a.

Source Error:

Line 1: <asp:TreeViewTreeView ID="TreeView1" Runat="server" Font-Underline="False"
Line 2: DataSourceId="XmlDataSource1"
Line 3: CollapseImageUrl="Images/CollapseImage.gif"


Source File: C:\Inetpub\vhosts\theplasticstore.com\httpdocs\test\nav.aspx Line: 1

Is the web site running ASP.NET 2.0 or is it running 1.1? You may have to set this in IIS so the pages are processed using the rigth framework if you have them installed side by side.


Yes, you can run all the .NET frameworks side by side on the same server. Open the properties for your web site and open the ASP.NET tab. Set teh ASP.NET version you wish to run. Here is a special note. Before you do this you will want to make sure you are in a separate APP Pool from any 1.1 applications or you will get worlds coliding. I create a new App Pool for each site on my servers so I can isolate them more and I think this is a good pratice to follow for many reasons. You can set the App Pool for a site in the Home Directory Tab, down at the bottom.

Saturday, March 24, 2012

newbie dropdownlist question

I'm sure this is obvious but.

I have an employee details form for an intranet to a sql server database. A number of controls in the form will be dropdown lists used as lookups. ie I have a jobno in the employee
table which would be linked to a jobsid in a jobs table. The only table which would be updated is the employee table.

I am using a separate datasets. I cant set the datatext to jobs.id and the datavalue to employee.jobno

The item shown in the list would be the employees id.

I don't know if the dataset would be the corect method?

Any assistance greatly appreciated.Write a query/view (woteva) using links to retrieve the required data for the dropdownlist and populate it into the same DataSet.

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 postback question about ASP controls

Do I understand correctly that my aspx webpage's DataGrid, Button and web
control states are somehow stored in the "_VIEWSTATE" hidden input value,
making it unneccesary to recreate their content in the case of page
postbacks? Or are there gotchas I need to look out for in assuming these
controls will work correctly, and have their former values available, after
a postback?
Thanks,
JimHi Jim,
You are correct for your server controls. The ones that start <asp:...>.
You can also add your HTML control to the _VIEWSTATE by giving them the
runat="Server" attribute. For example: <input type="hidden" id="hidValue"
runat="server"> will add this control to view state and it will retain its
value between postbacks. Good luck! Ken.
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
"Jim Bancroft" <bobgambles@.nowhere.com> wrote in message
news:epGzj$koEHA.3668@.TK2MSFTNGP15.phx.gbl...
> Do I understand correctly that my aspx webpage's DataGrid, Button and web
> control states are somehow stored in the "_VIEWSTATE" hidden input value,
> making it unneccesary to recreate their content in the case of page
> postbacks? Or are there gotchas I need to look out for in assuming these
> controls will work correctly, and have their former values available,
after
> a postback?
> Thanks,
> Jim
>
Thanks for the explanation and help, Ken! Good stuff below.
-Jim
"Ken Dopierala Jr." <kdopierala2@.wi.rr.com> wrote in message
news:%23FEbSHloEHA.2864@.TK2MSFTNGP12.phx.gbl...
> Hi Jim,
> You are correct for your server controls. The ones that start <asp:...>.
> You can also add your HTML control to the _VIEWSTATE by giving them the
> runat="Server" attribute. For example: <input type="hidden"
id="hidValue"
> runat="server"> will add this control to view state and it will retain its
> value between postbacks. Good luck! Ken.
> --