Showing posts with label following. Show all posts
Showing posts with label following. Show all posts

Saturday, March 31, 2012

Server side form tags

I recently ran into the following exception that I received when trying to add 2 forms to a single page:

System.Web.HttpException: A page can have only one server-side Form tag.
Does this mean that I can not use more than one form on an aspx page? Is there a way around this? This seems like it would be very restrictive if there isn't a way to handle more than one form per page...

Thanks.Correct, 1 server form per page.. you can have as many client forms as you want but just 1 server form.

It really shouldnt be an issue if you are programming the .NET way, when doing asp.net pages.

Paul Wilson does have a control that allows multiple server forms, i think its in the control gallery.

Monday, March 26, 2012

Server tags cannot contain <% ... %> constructs

<cc:SourceWindow id="SourceWindow1"
FileName="<%=Request.ServerVariables["PATH_INFO"]%>" RunAt="server" >
The above produces the following error:
Server tags cannot contain <% ... %> constructs.
Any idea, what to do here? I am an old ASP programmer.
Thanks for help !
LMJin your code for loading the page use :
SourceWindow1.FileName = [whatever]
"lm Jr" <lmJR@.aspdotnet.learner> wrote in message news:O%235EWkrjHHA.3264@.TK2MSFTNGP04.phx.
gbl...
> <cc:SourceWindow id="SourceWindow1" FileName="<%=Request.ServerVariables["
PATH_INFO"]%>" RunAt="server" >
> The above produces the following error:
> Server tags cannot contain <% ... %> constructs.
> Any idea, what to do here? I am an old ASP programmer.
> Thanks for help !
> LMJ
>
"lm Jr" <lmJR@.aspdotnet.learner> wrote in message
news:O%235EWkrjHHA.3264@.TK2MSFTNGP04.phx.gbl...
> <cc:SourceWindow id="SourceWindow1"
> FileName="<%=Request.ServerVariables["PATH_INFO"]%>" RunAt="server" >
> The above produces the following error:
> Server tags cannot contain <% ... %> constructs.
> Any idea, what to do here? I am an old ASP programmer.
In your Page_Load method, do this:
SourceWindow1.FileName = Request.ServerVariables["PATH_INFO"]
I strongly suggest you never use the technique you tried above. Substituting
directly into the rendered HTML can cause problems. For example, I've been
fighting today with user controls that do things like this:
<script language="javascript">
function Something()
{
var control = document.getElementById("<%= _someControl.ClientID %>");
}
</script>
This innocent piece of script causes one copy of itself to be created for
each instance on a page of the control containing it. Not a problem if the
script is small and there are few instances, but on one of our pages, each
script block is about 750 lines long, and there are over 10 instances of the
control on the same page. It adds up.
Good luck with ASP.NET. Please feel free to ask for help on these
newsgroups, and please try to learn the .NET way of doing things - there's a
reason why ASP.NET was invented, and that reason is ASP!
--
John Saunders [MVP]
Thanks for your suggestions. That was really helpful !!
LM J

Server Unavailable

Hi everybody,
I've got some big problems today. I turned on my web server this morning
and tried to access my site, and I got the following error in my browser:

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.

So I check the event log and there are 2 errors logged there:
aspnet_wp.exe could not be launched because the username and/or password
supplied in the processModel section of the config file are invalid

AND

aspnet_wp.exe could not be started. The error code for the failure is
80004005. This error can be caused when the worker process account has
insufficient rights to read the .NET Framework files. Please ensure that the
..NET Framework is correctly installed and that the ACLs on the installation
directory allow access to the configured account.

I looked at a couple dozen web sites trying to figure out what could be
wrong, but none of the solutions offered worked. I've tried reinstalling
ASP.net with and without first deleting the ASPNET user. I've changed the
username and password in the process model section of machine.config to
another local user. I've done pretty much everything anyone can tell me
thus far. The server is not a domain controller. The really weird thing is
that all of this was working fine when I left the office last night, and now
it doesn't work.
Anyone have any ideas? Please help.

Thanks, MattWe run into this problem quite a bit. For SOME reason (still not sure why), the following solution works every time:

1.) Go to Control Panel > Admin > Servives
2.) Select the ASPNET State Service
3.) Change the logon to the system account (click apply)
4.) Change the logon back to the ASPNET and clear the password (click apply)

Should be all set from there.

"Matt MacDonald" wrote:

> Hi everybody,
> I've got some big problems today. I turned on my web server this morning
> and tried to access my site, and I got the following error in my browser:
> 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.
> So I check the event log and there are 2 errors logged there:
> aspnet_wp.exe could not be launched because the username and/or password
> supplied in the processModel section of the config file are invalid
> AND
> aspnet_wp.exe could not be started. The error code for the failure is
> 80004005. This error can be caused when the worker process account has
> insufficient rights to read the .NET Framework files. Please ensure that the
> ..NET Framework is correctly installed and that the ACLs on the installation
> directory allow access to the configured account.
> I looked at a couple dozen web sites trying to figure out what could be
> wrong, but none of the solutions offered worked. I've tried reinstalling
> ASP.net with and without first deleting the ASPNET user. I've changed the
> username and password in the process model section of machine.config to
> another local user. I've done pretty much everything anyone can tell me
> thus far. The server is not a domain controller. The really weird thing is
> that all of this was working fine when I left the office last night, and now
> it doesn't work.
> Anyone have any ideas? Please help.
> Thanks, Matt
>

Server Unavailable

Hi everybody,
I've got some big problems today. I turned on my web server this morning
and tried to access my site, and I got the following error in my browser:
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.
So I check the event log and there are 2 errors logged there:
aspnet_wp.exe could not be launched because the username and/or password
supplied in the processModel section of the config file are invalid
AND
aspnet_wp.exe could not be started. The error code for the failure is
80004005. This error can be caused when the worker process account has
insufficient rights to read the .NET Framework files. Please ensure that the
.NET Framework is correctly installed and that the ACLs on the installation
directory allow access to the configured account.
I looked at a couple dozen web sites trying to figure out what could be
wrong, but none of the solutions offered worked. I've tried reinstalling
ASP.net with and without first deleting the ASPNET user. I've changed the
username and password in the process model section of machine.config to
another local user. I've done pretty much everything anyone can tell me
thus far. The server is not a domain controller. The really weird thing is
that all of this was working fine when I left the office last night, and now
it doesn't work.
Anyone have any ideas? Please help.
Thanks, MattWe run into this problem quite a bit. For SOME reason (still not sure why),
the following solution works every time:
1.) Go to Control Panel > Admin > Servives
2.) Select the ASPNET State Service
3.) Change the logon to the system account (click apply)
4.) Change the logon back to the ASPNET and clear the password (click apply)
Should be all set from there.
"Matt MacDonald" wrote:

> Hi everybody,
> I've got some big problems today. I turned on my web server this mornin
g
> and tried to access my site, and I got the following error in my browser:
> 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 browse
r
> 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 serve
r.
> Please review this log entry to discover what caused this error to occur.
> So I check the event log and there are 2 errors logged there:
> aspnet_wp.exe could not be launched because the username and/or password
> supplied in the processModel section of the config file are invalid
> AND
> aspnet_wp.exe could not be started. The error code for the failure is
> 80004005. This error can be caused when the worker process account has
> insufficient rights to read the .NET Framework files. Please ensure that t
he
> ..NET Framework is correctly installed and that the ACLs on the installati
on
> directory allow access to the configured account.
> I looked at a couple dozen web sites trying to figure out what could be
> wrong, but none of the solutions offered worked. I've tried reinstalling
> ASP.net with and without first deleting the ASPNET user. I've changed the
> username and password in the process model section of machine.config to
> another local user. I've done pretty much everything anyone can tell me
> thus far. The server is not a domain controller. The really weird thing
is
> that all of this was working fine when I left the office last night, and n
ow
> it doesn't work.
> Anyone have any ideas? Please help.
> Thanks, Matt
>
>

Saturday, March 24, 2012

Server.CreateObject: Making objects visible

I would like to make an DCOM-object created by an ASP page visible for debugging purposes.
For instance: I have the following code:

SET objExcel = Server.CreateObject("Excel.Application.10")
objExcel.Application.Visible = True
SET Session.Contents("myexcel") = objExcel

When I run this code, the Excel object is created and stored in a session variable for later use. However, on my machine it is not visible, although I have set the visible property to True.
I can see that the EXCEL object was created by opening in the process page of the WINDOWS Task-Manager
I tried also to Server.CreateObject several other objects with the same result: Although I have set the visible property to true they just do not show up.
What me make wondering about this is that a couple a weeks ago everything worked fine, the Server.Created objects were visible, but I must have changed something on my machine because now they remain invisible.
Does anybody has a clue on this?Just found the solution:
in the DCOM-Configuration the identity must be Interactive User (NOT user who started the application)
Already thought this was a Windows Privileges problem
I've been having the same problem - getting Excel to become visible. How do you configure the identity to be Interactive User? Is it in the dcomcnfg utility?

When I run my app, I can see EXCEL.EXE in my task manager, but it is not visible and I, too, use the visible=true setting.

It's been plaguing me for about a week now.
I'm a bit new, so go easy....

Rykri11
Yes with Windows 2000 you'll have to run dcomcnfg.exe while with WindowsXP you'll also find it at computer administration (component services)
Then you need to find your application (MS Excel) and edit the properties of this application (right-mouse click with XP, push-button with Windows 2000). On the 4th page named "identity" of the page selector you'll need to set the user to "interactive user"

Thursday, March 22, 2012

Server.HTMLEncode

Hi,
The following is lifted straight from the MSDN help topic for
HttpServerUtility.HtmlEncode Method [C#]
---
The following example encodes a string for transmission by HTTP. It encodes
the string named TestString, which contains the text "This is a <Test
String>.", and copies it into the string named EncodedString as
"This+is+a+%3cTest+String%3e.".
[C#]
String TestString = "This is a <Test String>.";
StringWriter writer = new StringWriter();
Server.HtmlEncode(TestString, writer);
String EncodedString = writer.ToString();
---
However, when I run it, the value of EncodedString is "This is a <Test
String>." not "This+is+a+%3cTest+String%3e."
Am I missing something? Am I not using the correct encoding method?
Any assistance gratefully received.
Best,
Mark RaeHi,
Use Server.UrlEncode for the output you are expecting.
"Mark Rae" <mark@.mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:eBm3iJ$cEHA.592@.TK2MSFTNGP11.phx.gbl...
Hi,
The following is lifted straight from the MSDN help topic for
HttpServerUtility.HtmlEncode Method [C#]
---
The following example encodes a string for transmission by HTTP. It encodes
the string named TestString, which contains the text "This is a <Test
String>.", and copies it into the string named EncodedString as
"This+is+a+%3cTest+String%3e.".
[C#]
String TestString = "This is a <Test String>.";
StringWriter writer = new StringWriter();
Server.HtmlEncode(TestString, writer);
String EncodedString = writer.ToString();
---
However, when I run it, the value of EncodedString is "This is a <Test
String>." not "This+is+a+%3cTest+String%3e."
Am I missing something? Am I not using the correct encoding method?
Any assistance gratefully received.
Best,
Mark Rae
Mark Rae wrote:

> Hi,
> The following is lifted straight from the MSDN help topic for
> HttpServerUtility.HtmlEncode Method [C#]
> ---
> The following example encodes a string for transmission by HTTP. It encode
s
> the string named TestString, which contains the text "This is a <Test
> String>.", and copies it into the string named EncodedString as
> "This+is+a+%3cTest+String%3e.".
> [C#]
> String TestString = "This is a <Test String>.";
> StringWriter writer = new StringWriter();
> Server.HtmlEncode(TestString, writer);
> String EncodedString = writer.ToString();
> ---
> However, when I run it, the value of EncodedString is "This is a <Test
> String>." not "This+is+a+%3cTest+String%3e."
> Am I missing something? Am I not using the correct encoding method?
> Any assistance gratefully received.
> Best,
> Mark Rae
>
Try Server.UrlEncode instead. HtmlEncode is generating HTML, as it
would be expected to.
-Mike
"Mike Newton" <MNewton@.Addus.com> wrote in message
news:ewkETQ$cEHA.2236@.TK2MSFTNGP10.phx.gbl...
Mike & Silva,

> Try Server.UrlEncode instead. HtmlEncode is generating HTML, as it
> would be expected to.
Thanks very much. Is the MSDN topic wrong, then...?

Server.HTMLEncode

Hi,

The following is lifted straight from the MSDN help topic for
HttpServerUtility.HtmlEncode Method [C#]

-------------------
The following example encodes a string for transmission by HTTP. It encodes
the string named TestString, which contains the text "This is a <Test
String>.", and copies it into the string named EncodedString as
"This+is+a+%3cTest+String%3e.".

[C#]
String TestString = "This is a <Test String>.";
StringWriter writer = new StringWriter();
Server.HtmlEncode(TestString, writer);
String EncodedString = writer.ToString();
-------------------

However, when I run it, the value of EncodedString is "This is a <Test
String>." not "This+is+a+%3cTest+String%3e."

Am I missing something? Am I not using the correct encoding method?

Any assistance gratefully received.

Best,

Mark RaeHi,

Use Server.UrlEncode for the output you are expecting.

"Mark Rae" <mark@.mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:eBm3iJ$cEHA.592@.TK2MSFTNGP11.phx.gbl...
Hi,

The following is lifted straight from the MSDN help topic for
HttpServerUtility.HtmlEncode Method [C#]

-------------------
The following example encodes a string for transmission by HTTP. It encodes
the string named TestString, which contains the text "This is a <Test
String>.", and copies it into the string named EncodedString as
"This+is+a+%3cTest+String%3e.".

[C#]
String TestString = "This is a <Test String>.";
StringWriter writer = new StringWriter();
Server.HtmlEncode(TestString, writer);
String EncodedString = writer.ToString();
-------------------

However, when I run it, the value of EncodedString is "This is a <Test
String>." not "This+is+a+%3cTest+String%3e."

Am I missing something? Am I not using the correct encoding method?

Any assistance gratefully received.

Best,

Mark Rae
Mark Rae wrote:

> Hi,
> The following is lifted straight from the MSDN help topic for
> HttpServerUtility.HtmlEncode Method [C#]
> -------------------
> The following example encodes a string for transmission by HTTP. It encodes
> the string named TestString, which contains the text "This is a <Test
> String>.", and copies it into the string named EncodedString as
> "This+is+a+%3cTest+String%3e.".
> [C#]
> String TestString = "This is a <Test String>.";
> StringWriter writer = new StringWriter();
> Server.HtmlEncode(TestString, writer);
> String EncodedString = writer.ToString();
> -------------------
> However, when I run it, the value of EncodedString is "This is a <Test
> String>." not "This+is+a+%3cTest+String%3e."
> Am I missing something? Am I not using the correct encoding method?
> Any assistance gratefully received.
> Best,
> Mark Rae

Try Server.UrlEncode instead. HtmlEncode is generating HTML, as it
would be expected to.

-Mike
"Mike Newton" <MNewton@.Addus.com> wrote in message
news:ewkETQ$cEHA.2236@.TK2MSFTNGP10.phx.gbl...

Mike & Silva,

> Try Server.UrlEncode instead. HtmlEncode is generating HTML, as it
> would be expected to.

Thanks very much. Is the MSDN topic wrong, then...?

Server.HTMLDecode........

i hav the following codes:
strSql="Select PMS_Leave.Reasons from table"
.
.
.
.
ds=New DataSet
dGrdLoc.DataSource=nothing
dGrdLoc.DataBind()
dt=New SqlDataAdapter(strSql,con)
dt.Fill(ds)
dGrdLoc.DataSource=ds
dGrdLoc.DataBind()

<asp:DataGrid id="dGrdLoc" Runat="Server">
<column>
<asp:TemplateColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="100" HeaderStyle-HorizontalAlign="Center" HeaderStyle-CssClass="content_title" HeaderText="Reasons">
<ItemTemplate >
<asp:label id="Label1" text=<%#Container.DataItem("Reasons")%> runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
.
.
.

The columnfiled Reasons has been encoded using Server.HTMLEncode before entering the DB, my problem is i dont know where to write the Server.HTMLDecode to decode it...
plz helpI think you could just place it around the container tag like this:


<asp:Label id="label1" text="<%# Server.HTMLDecode(Container.DataItem("Reasons"))%>" runat="server" />

regards,

Maurits

Tuesday, March 13, 2012

server.mappath challenging problem

I created a page that uses the following line in it.:

Public votingDatabasePath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("/datasources/votingDB.mdb")

and the page worked brilliantly.
I then changed this into a web user control, and the program always crashes on this line saying the following. The weird thing is that I load the user control in a try catch statement, so the page should never go to the full error page.

Any help would be greatly appriciated.

Jagdip

---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@dotnet.itags.org. Page Language="C#" Debug="true" %
or:

2) Add the following section to the configuration file of your application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
---------------------------
Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.UI.UserControl.get_Server() +8
_test.jags_voting..ctor() in C:\Documents and Settings\.....voting\jags_voting.ascx.vb:18
ASP.jags_voting_ascx..ctor()

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) +0
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.PartialCachingControl.CreateCachedControl() +225
System.Web.UI.BasePartialCachingControl.OnInit(EventArgs e) +93
System.Web.UI.Control.InitRecursive(Control namingContainer) +241
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.AddedControl(Control control, Int32 index) +185
System.Web.UI.ControlCollection.Add(Control child) +153
_test.JagsDTGDashboard.writePanels() in C:\Documents and Settings\.....\JagsDTGDashboard.aspx.vb:666
_test.JagsDTGDashboard.dropDownListIndexChanged(Object sender, EventArgs e) in C:\Documents and Settings\....\JagsDTGDashboard.aspx.vb:259
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +108
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +26
System.Web.UI.Page.RaiseChangedEvents() +115
System.Web.UI.Page.ProcessRequestMain() +1072Server is not a property ofWebControl orControl, which are inherited by theUser Control. You have to reference Server via the Page property:

Public votingDatabasePath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &Page.Server.mappath("/datasources/votingDB.mdb")

I'm afraid that that has not solved the problem. The same error appears.

I'm just wondering what the ..ctor() means in

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.UI.UserControl.get_Server() +8
_test.jags_voting..ctor() in C:\Documents and Settings\.....voting\jags_voting.ascx.vb:18
ASP.jags_voting_ascx..ctor()

Jagdip
I'm pretty sure that ..ctor() means 'constructor'. the control is failing to get created. With web controls, I have found that I have to make sure that any relative paths are relative to the parent page that will run the control. If your page that hosts the control is in a different folder from the control, the results are a little unpredictable.

Server.MapPath Failing When Moved to Class Module

In a VB/ASP.NET project, the following lines work as advertised when placed
in a code-behind file (whatever.aspx.vb) - meaning that I get the full
physical path to MyDatabase.MDB in the variable PathToMDB. However, when the
same two lines are moved to a separate class file (whatever.vb), the project
fails to build - with the message "Name 'Server' is not declared."

Dim PathToMDB As String
PathToMDB = Server.MapPath("/MySite/db/") + "MyDatabase.mdb"

Why is this? What can I do about it? I need to obtain the physical path to
the MDB file from within the class file.

Thanks in advance."Jeff S" <JeffS@.asdf.net> wrote in message
news:uloQjlvoDHA.1928@.TK2MSFTNGP12.phx.gbl...
> In a VB/ASP.NET project, the following lines work as advertised when
placed
> in a code-behind file (whatever.aspx.vb) - meaning that I get the full
> physical path to MyDatabase.MDB in the variable PathToMDB. However, when
the
> same two lines are moved to a separate class file (whatever.vb), the
project
> fails to build - with the message "Name 'Server' is not declared."
> Dim PathToMDB As String
> PathToMDB = Server.MapPath("/MySite/db/") + "MyDatabase.mdb"
>
> Why is this? What can I do about it? I need to obtain the physical path to
> the MDB file from within the class file.
> Thanks in advance.

Try
HttpContext.Current.Server.MapPath("/MySite/db/") + "MyDatabase.mdb"

--
[[((hillarie))]]

To reply by email, remove ".SPAMBLOCK" from email address
Try it in this format:
MyConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
server.mappath("/") & "../data/myDB.mdb;"

David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com

"Jeff S" <JeffS@.asdf.net> wrote in message
news:uloQjlvoDHA.1928@.TK2MSFTNGP12.phx.gbl...
> In a VB/ASP.NET project, the following lines work as advertised when
placed
> in a code-behind file (whatever.aspx.vb) - meaning that I get the full
> physical path to MyDatabase.MDB in the variable PathToMDB. However, when
the
> same two lines are moved to a separate class file (whatever.vb), the
project
> fails to build - with the message "Name 'Server' is not declared."
> Dim PathToMDB As String
> PathToMDB = Server.MapPath("/MySite/db/") + "MyDatabase.mdb"
>
> Why is this? What can I do about it? I need to obtain the physical path to
> the MDB file from within the class file.
> Thanks in advance.