Showing posts with label header. Show all posts
Showing posts with label header. Show all posts

Saturday, March 31, 2012

separate HTML from codebehind for user control page

I have a site that uses header.ascx as a user control for the Top Menu. I'm trying (to do it the right way) to separate the HTML code from the codebehind but I'm having a difficult time w/ it... I looked at some articles on codebehinds but most of them are event driven like if you click on a button and some event happens... but for my page, I just want to display a menu at a specific location when the form loads... I guess I have to put it in a function and then call it from my main page? But I'm not sure how??
============================
header.ascx
============================
<%@dotnet.itags.org. Control Language="vb" AutoEventWireup="false" Codebehind="header.ascx.vb" Inherits="intranet.header" %>

============================
header.ascx.vb
============================
PublicClass nav_header
Inherits System.Web.UI.UserControl
Public strPageTitleAsString
Public strTopMenu1AsString

PrivateSub Page_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load

Response.Write("<title>" & strPageTitle & "</title>")
Response.Write("</head><body>")
Response.Write("<table><tr><td>test...</td></tr>")
Response.Write("<tr><td><table><tr>")

Dim strTopMenu2()AsString
SelectCase strTopMenu1

Case "Header 1"
strTopMenu=NewString() {"Corporate_CatHeader1", "../Corporate/header1.aspx", "Corporate_CatHeader2", "../Corporate/header2.aspx"}
Case "Header 2"
strTopMenu =NewString() {"Practices_CatHeader1", "../Practices/header1.aspx", "Practices_CatHeader2", "../Practices/header2.aspx"}
Case "Header 3"
strTopMenu =NewString() {"WebMail_CatHeader1", "../WebMail/header1.aspx", "WebMail_CatHeader2", "../WebMail/header2.aspx"}
CaseElse' no menu requested, so include a blank spacer

ExitSub
EndSelect

Dim intTopMenu2ItemAsInteger
Dim intSelectedTopMenu1AsInteger
Dim iAsInteger

intSelectedTopMenu1 = (intTopMenu2Item - 1) * 2
For intTopMenu2Item = 0To UBound(strTopMenu2)Step 2
Response.Write("<td> <A href='" & strTopMenu2(intTopMenu2Item + 1) & "'>" & strTopMenu2(intTopMenu2Item) & "</a>")
Response.Write(" | </td>" & vbCrLf)

Next

Response.Write("</tr></table>")
Response.Write("</td></tr></table>")

EndSub

EndClass

In the inherits atribute of your page ensure it matches your class name. In this case your class name is nav_header but the inherits is intranet.header. For starters if you are not using Visual Studio then the intranet part is not necessary unless you wish to encompass the class in a namespace. The quick solution is to change inherits to header and the class name to header.
Sorry I mistyped some of the names... here's a short version.. please help..
===============
header.ascx
===============
<%@. Control Language="vb" AutoEventWireup="false" Codebehind="header.ascx.vb" Inherits="myapp.header" %>
<table><tr>
<td>
How can I display the test() here??
</td>
</tr></table>
===============
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
End Sub
Private Sub test()
Response.Write("test")
End Sub
End Class
Have you tried inherits="header" instead of myapp.header?

Thursday, March 29, 2012

Separating my VB classes into different files

Here's my scenario: I have a page default.aspx with the header directive
<%@dotnet.itags.org. Page aspcompat=true Language="VB" Debug="true" Inherits="forms" src="http://pics.10026.com/?src=forms.vb"%>
So I have the file forms.vb that contains the class "Forms", and that class references some custom controls I've made such as "FormPageControl" and it works just fine when I have FormPageControl defined in forms.vb, which I can do, but I want to be able to give it its own vb file, so I made a file called "FormPageControl.vb" and moved the class into that file. But how do I link forms.vb to FormPageControl.vb (like in C++ I would use the line: #include "FormPageControl.h" is there something simmilar in VB.NET so that the Just in Time compiler knows to look in FormPageControl.vb for the class named FormPageControl?

Is FormPageControl a user control? If so just use the @.Controltag to declare it on the aspx page and put it in a separate ascx file.
http://www.ondotnet.com/pub/a/dotnet/excerpt/progaspdotnet_14/index1.html

FormPageControl is a vb class that inherits Repeater. There is no ascx file associated with it
What's the error you are getting when you try to compile? Make sure you have the appropriate Imports statement.

Monday, March 26, 2012

Sequential numbers without a database?

Hi all,

I'd building an app that posts to a web service. One of the things
that is required in the soap header is a sequential number appended to
a ref, i.e. "IGI1001", "IGI1002", etc.

Obviously the first part of the reference ("IGI") stays the same, but
I need an incrementing number generated. Now, I was thinking of doing
this via a SQL database, but it would be an awful waste as there would
only be one table and one stored procedure in it. Then I was thinking
of putting it in an application variable: it would be read from a file
at the application start, incremented through the life of the
application, then written back to the file at application end. I
quickly discounted that in case the new number didn't get written back
to the file for whatever reason.

Incidentally, the web service expects the caller to provide the
incrementing alpha-numeric reference, so it won't be done at the web
service.

Any thoughts?

Kind regards,

Mike KingscottHallo Mike
"Mike Kingscott" <mike@.kingscott.f9.co.uk> schrieb im Newsbeitrag
news:7d9b584d.0407010225.3365dc16@.posting.google.c om...
> Hi all,
> I'd building an app that posts to a web service. One of the things
> that is required in the soap header is a sequential number appended to
> a ref, i.e. "IGI1001", "IGI1002", etc.
> Obviously the first part of the reference ("IGI") stays the same, but
> I need an incrementing number generated. Now, I was thinking of doing
> this via a SQL database, but it would be an awful waste as there would
> only be one table and one stored procedure in it. Then I was thinking
> of putting it in an application variable: it would be read from a file
> at the application start, incremented through the life of the
> application, then written back to the file at application end. I
> quickly discounted that in case the new number didn't get written back
> to the file for whatever reason.
> Incidentally, the web service expects the caller to provide the
> incrementing alpha-numeric reference, so it won't be done at the web
> service.
> Any thoughts?
> Kind regards,
> Mike Kingscott

I think, wether it is a waste, to use a sql database. its the safest way to
ensure there is always an incremented number.

regards benni
Any chance you could use a timestamp, or a GUID in the headers to make
them unique? Or does it absolutely have to be a sequential number?

Perhaps you could use a combination of incremented number and a
TimeStamp. The TimeStamp could be the time at which the application
started, say with DateTime.Now.Ticks. The sequential ID could then be
a static field that you increment with the Interlocked.Increment
method.

Possible?

--
Scott
http://www.OdeToCode.com

On 1 Jul 2004 03:25:58 -0700, mike@.kingscott.f9.co.uk (Mike Kingscott)
wrote:

>Hi all,
>I'd building an app that posts to a web service. One of the things
>that is required in the soap header is a sequential number appended to
>a ref, i.e. "IGI1001", "IGI1002", etc.
>Obviously the first part of the reference ("IGI") stays the same, but
>I need an incrementing number generated. Now, I was thinking of doing
>this via a SQL database, but it would be an awful waste as there would
>only be one table and one stored procedure in it. Then I was thinking
>of putting it in an application variable: it would be read from a file
>at the application start, incremented through the life of the
>application, then written back to the file at application end. I
>quickly discounted that in case the new number didn't get written back
>to the file for whatever reason.
>Incidentally, the web service expects the caller to provide the
>incrementing alpha-numeric reference, so it won't be done at the web
>service.
>Any thoughts?
>Kind regards,
>Mike Kingscott

Sequential numbers without a database?

Hi all,
I'd building an app that posts to a web service. One of the things
that is required in the soap header is a sequential number appended to
a ref, i.e. "IGI1001", "IGI1002", etc.
Obviously the first part of the reference ("IGI") stays the same, but
I need an incrementing number generated. Now, I was thinking of doing
this via a SQL database, but it would be an awful waste as there would
only be one table and one stored procedure in it. Then I was thinking
of putting it in an application variable: it would be read from a file
at the application start, incremented through the life of the
application, then written back to the file at application end. I
quickly discounted that in case the new number didn't get written back
to the file for whatever reason.
Incidentally, the web service expects the caller to provide the
incrementing alpha-numeric reference, so it won't be done at the web
service.
Any thoughts?
Kind regards,
Mike KingscottHallo Mike
"Mike Kingscott" <mike@.kingscott.f9.co.uk> schrieb im Newsbeitrag
news:7d9b584d.0407010225.3365dc16@.posting.google.com...
> Hi all,
> I'd building an app that posts to a web service. One of the things
> that is required in the soap header is a sequential number appended to
> a ref, i.e. "IGI1001", "IGI1002", etc.
> Obviously the first part of the reference ("IGI") stays the same, but
> I need an incrementing number generated. Now, I was thinking of doing
> this via a SQL database, but it would be an awful waste as there would
> only be one table and one stored procedure in it. Then I was thinking
> of putting it in an application variable: it would be read from a file
> at the application start, incremented through the life of the
> application, then written back to the file at application end. I
> quickly discounted that in case the new number didn't get written back
> to the file for whatever reason.
> Incidentally, the web service expects the caller to provide the
> incrementing alpha-numeric reference, so it won't be done at the web
> service.
> Any thoughts?
> Kind regards,
> Mike Kingscott
I think, wether it is a waste, to use a sql database. its the safest way to
ensure there is always an incremented number.
regards benni
Any chance you could use a timestamp, or a GUID in the headers to make
them unique? Or does it absolutely have to be a sequential number?
Perhaps you could use a combination of incremented number and a
TimeStamp. The TimeStamp could be the time at which the application
started, say with DateTime.Now.Ticks. The sequential ID could then be
a static field that you increment with the Interlocked.Increment
method.
Possible?
Scott
http://www.OdeToCode.com
On 1 Jul 2004 03:25:58 -0700, mike@.kingscott.f9.co.uk (Mike Kingscott)
wrote:

>Hi all,
>I'd building an app that posts to a web service. One of the things
>that is required in the soap header is a sequential number appended to
>a ref, i.e. "IGI1001", "IGI1002", etc.
>Obviously the first part of the reference ("IGI") stays the same, but
>I need an incrementing number generated. Now, I was thinking of doing
>this via a SQL database, but it would be an awful waste as there would
>only be one table and one stored procedure in it. Then I was thinking
>of putting it in an application variable: it would be read from a file
>at the application start, incremented through the life of the
>application, then written back to the file at application end. I
>quickly discounted that in case the new number didn't get written back
>to the file for whatever reason.
>Incidentally, the web service expects the caller to provide the
>incrementing alpha-numeric reference, so it won't be done at the web
>service.
>Any thoughts?
>Kind regards,
>Mike Kingscott

Tuesday, March 13, 2012

Server Application Unavailable

Issue:

We are hosting multiple Community Server sites on the same IP address using a host header running on 1.1 .NET Framework; also on the same server we are hosting sites running on the 2.0 .NET Framework. We average about three days of the site running and than we get the following error:

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.

Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

Fix:

Basically we would fix this by opening a command window and go to C:\WINDOWS\Microsoft.NET\Framweork\v1.1.4322 and typing aspnet_regiis-s W3SVC/1/ROOT/ and here we would enter the folder name or application. In this case we have named the folder VisualStudioToolsForOffice.com to reflect the domain visualstudiotoolsforoffice.com, so the full command would be aspnet_regiis -s W3SVC/1/ROOT/VisualStudioToolsForOffice.com. On doing this, we get this error:

C:\WINDOWS/Microsoft.NET\Framework\v1.14322>aspnet_regiis -s W3SVC/1/ROOT/visualstudiotoolsforoffice.com

Start registering ASP.NET scriptmap (1.1.4322.0) recursively at W3SVC/1/ROOT/visualstudiotoolsforoffice.com) is not a valid we application.

Installation stopped because the specified path (W3SVC/1/ROOT/visualstudiotoolsforoffice.com) is not a valid web application.

Here is the only way we have found to fix this: go to the Internet Information Services Manager (IIS), select websites and select the webite (in this case, visualstudiotooldforoffice.com), right click and select properties, select the ASP.NET tab, go to the drop down box for the ASP.NET version, select the 2.0 version and click apply and ok; right click and then selct properties, select the ASP.NET tab, then go to the drop down box for the ASP.NET version, select the 1.1 version and click apply and okay. Finally - NO server application unavailable error!. Any help from the community on a better resolve on this would be greatly appreciated, as going and repairing this every three days is a nuisance. Thanks in advance.

Okay, someone correct me if I am wrong, to install the scritpmaps, go to c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 and then type:

aspnet_regiis -s W3SVC/1/ROOT/VisualStudioToolsForOffice

VisualStudioToolsForOffice being the name of the application, so why am I still getting:

Start registering ASP.NET scriptmap (1.1.4322.0) recursively at W3SVC/1/ROOT/visualstudiotoolsforoffice.com) is not a valid we application.

Installation stopped because the specified path (W3SVC/1/ROOT/visualstudiotoolsforoffice.com) is not a valid web application.


I had the same problem and found a solution. First go to de IIS Admin Console, click on Web Sites a look for the identifier (a big number) of the site you want to upgrade de scriptmap. Then open a Command Line Console and typeaspnet_regiis -lk. It shows you the versions of the frameworks for each site. On this list find the line with the same identifier. Then type aspnet_regiis -s W3SVC/[identifier]/root/[optional if you have nested sites o directories].
Finally typeaspnet_regiis -lk again to check if it worked correctly. That's all.
LKZ:

Hello Kevin,

As far as I know, If you're trying to map that application to run under ASP.NET 1.1, I think you are doing it in the proper way.

I do not understand why raises that error. Those are the instructions stated in the Beta Doc and a book I've checked a few minutes ago about remapping web apps.
However, it may happen that the something could change about this since then, and the documentation it is not updated yet.
Good luck.


LuKiller wrote:

I had the same problem and found a solution. First go to de IIS Admin Console, click on Web Sites a look for the identifier (a big number) of the site you want to upgrade de scriptmap. Then open a Command Line Console and typeaspnet_regiis -lk. It shows you the versions of the frameworks for each site. On this list find the line with the same identifier. Then type aspnet_regiis -s W3SVC/[identifier]/root/[optional if you have nested sites o directories].
Finally typeaspnet_regiis -lk again to check if it worked correctly. That's all.
LKZ:


Okay, I ran aspnet_regiis -lk to list the site's and identifiers. Than I ran aspnet_regiis -s W3SVC/1903649274/root/VisualStudioToolsForOffice to set the scriptmaps and I still got the "Installation stopped because the specified path W3SVC/1903649274/root/visualstudiotoolsforoffice) is not a valid web application".
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>aspnet_regiis /lk
W3SVC/ 1.1.4322.0
W3SVC/1/ROOT/ 1.1.4322.0
W3SVC/1/ROOT/CertSrv/ 2.0.50215.44
W3SVC/1154147039/root/ 2.0.50215.44
W3SVC/1771324749/root/ 2.0.50215.44
W3SVC/1818541202/root/ 2.0.50215.44
W3SVC/1903649274/root/ 1.1.4322.0
W3SVC/53732026/root/ 1.1.4322.0
W3SVC/701625/root/ 1.1.4322.0

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>aspnet_regiis -s W3SVC/1903649274/r
oot/visualstudiotoolsforoffice
Start registering ASP.NET scriptmap (1.1.4322.0) recursively at W3SVC/1903649274
/root/visualstudiotoolsforoffice.
Installation stopped because the specified path (W3SVC/1903649274/root/visualstu
diotoolsforoffice) is not a valid web application.