Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Thursday, March 29, 2012

Newbie -- Page_Load( ) fires twice if image is added to Login page

Hi,
I'm using Visual Studio 2005 + ASP.NET and C#
I have a login.aspx page with AutoEventWireup set to FALSE (also added to
top level Web.Config, and set to false)
With a "template" loginCtl the Page_Load( ) event fires once.
As soon as I add an ImageCtl or just drag an image using the designer, onto
the login page and then run it, I'm seeing the Page_Init( ) and Page_Load( )
functions being fired twice.
If I remove the image, then these methods are only fired once.
Any ideas?
I am setting the event delegate like this in my login.aspx.cs file:
protected override void OnInit( EventArgs e )
{
this.Load += new EventHandler( Page_Load );
}
protected void Page_Load( ... etc.
Thanks for any tips,
FrankThis isn't a direct answer, but I personally avoid that this.Load += new
EventHandler(Page_Load) stuff that the wizard puts in like the plague. The
reason being is that I subclass pages a lot, and when you depend on wiring
up events, you can run into issues where a subclass won't call the base
initializer, or the listeners get added in an order that prevents proper
handling (I'd have to dig up an example, but I had issues with Page_Load
never firing at all). Since you're overriding OnInit just to wire up an
event handler, I'd just override OnLoad and see if that might prevent the
double-hit (plus, you're plugging into the vtable instead of having to deal
with event firing/delegate calling)

Newbie -- Page_Load( ) fires twice if image is added to Login page

Hi,

I'm using Visual Studio 2005 + ASP.NET and C#

I have a login.aspx page with AutoEventWireup set to FALSE (also added to
top level Web.Config, and set to false)

With a "template" loginCtl the Page_Load( ) event fires once.

As soon as I add an ImageCtl or just drag an image using the designer, onto
the login page and then run it, I'm seeing the Page_Init( ) and Page_Load( )
functions being fired twice.

If I remove the image, then these methods are only fired once.

Any ideas?

I am setting the event delegate like this in my login.aspx.cs file:

protected override void OnInit( EventArgs e )
{
this.Load += new EventHandler( Page_Load );
}

protected void Page_Load( ... etc.

Thanks for any tips,

FrankThis isn't a direct answer, but I personally avoid that this.Load += new
EventHandler(Page_Load) stuff that the wizard puts in like the plague. The
reason being is that I subclass pages a lot, and when you depend on wiring
up events, you can run into issues where a subclass won't call the base
initializer, or the listeners get added in an order that prevents proper
handling (I'd have to dig up an example, but I had issues with Page_Load
never firing at all). Since you're overriding OnInit just to wire up an
event handler, I'd just override OnLoad and see if that might prevent the
double-hit (plus, you're plugging into the vtable instead of having to deal
with event firing/delegate calling)

newbie - stupid install question

Hi,

i FPTed my files to my host ISP. Now i can browse to
www.mysite.com/WebForm1.aspx. The problem is that my ISP runs index.html
at www.mysite.com. If i delete index.html i get "HTTP Error 403 -
Forbidden" at www.mysite.com. How do i get www.mysite.com to display
WebForm1.aspx?

Thanks,
MarkIn addition to index.html, your host will look for default.aspx (presuming it
supports asp.net, which is not the case with many hosters). The search order
depends on how IIS is configured (in IIS you can specify which pages to use
as the default, and in which order it looks for them, but your hoster likely
won't let you get at this).

So, get rid of index.html and rename your web form to default.aspx. Or, make
default.aspx or index.html a list of links to your real pages. Or, navigate
directly to mysite.com/webform1.aspx.

Bill

"Mark Oliver" wrote:

> Hi,
> i FPTed my files to my host ISP. Now i can browse to
> www.mysite.com/WebForm1.aspx. The problem is that my ISP runs index.html
> at www.mysite.com. If i delete index.html i get "HTTP Error 403 -
> Forbidden" at www.mysite.com. How do i get www.mysite.com to display
> WebForm1.aspx?
> Thanks,
> Mark
>
>
There is a setting in IIS for a defualt document. The file can by anything
including WebForm1.aspx. Your host should have a control panel where you can
control this option. There is a default asp.net file with IIS, it is
default.aspx. I suggest you use this instead of WebForm1.aspx. It will make
moving your project to different servers easier.

HTH MikeL

"Mark Oliver" wrote:

> Hi,
> i FPTed my files to my host ISP. Now i can browse to
> www.mysite.com/WebForm1.aspx. The problem is that my ISP runs index.html
> at www.mysite.com. If i delete index.html i get "HTTP Error 403 -
> Forbidden" at www.mysite.com. How do i get www.mysite.com to display
> WebForm1.aspx?
> Thanks,
> Mark
>
>
renaming to index.aspx works great!
Thanks Bill and MikeL
Mark

"Mark Oliver" <camarkco@.hotmail.com> wrote in message
news:8bCdnaLdHKKcAQLcRVn-gg@.adelphia.com...
> Hi,
> i FPTed my files to my host ISP. Now i can browse to
> www.mysite.com/WebForm1.aspx. The problem is that my ISP runs index.html
> at www.mysite.com. If i delete index.html i get "HTTP Error 403 -
> Forbidden" at www.mysite.com. How do i get www.mysite.com to display
> WebForm1.aspx?
> Thanks,
> Mark

newbie - stupid install question

Hi,
i FPTed my files to my host ISP. Now i can browse to
www.mysite.com/WebForm1.aspx. The problem is that my ISP runs index.html
at www.mysite.com. If i delete index.html i get "HTTP Error 403 -
Forbidden" at www.mysite.com. How do i get www.mysite.com to display
WebForm1.aspx?
Thanks,
MarkIn addition to index.html, your host will look for default.aspx (presuming i
t
supports asp.net, which is not the case with many hosters). The search order
depends on how IIS is configured (in IIS you can specify which pages to use
as the default, and in which order it looks for them, but your hoster likely
won't let you get at this).
So, get rid of index.html and rename your web form to default.aspx. Or, make
default.aspx or index.html a list of links to your real pages. Or, navigate
directly to mysite.com/webform1.aspx.
Bill
"Mark Oliver" wrote:

> Hi,
> i FPTed my files to my host ISP. Now i can browse to
> www.mysite.com/WebForm1.aspx. The problem is that my ISP runs index.html
> at www.mysite.com. If i delete index.html i get "HTTP Error 403 -
> Forbidden" at www.mysite.com. How do i get www.mysite.com to display
> WebForm1.aspx?
> Thanks,
> Mark
>
>
There is a setting in IIS for a defualt document. The file can by anything
including WebForm1.aspx. Your host should have a control panel where you ca
n
control this option. There is a default asp.net file with IIS, it is
default.aspx. I suggest you use this instead of WebForm1.aspx. It will mak
e
moving your project to different servers easier.
HTH MikeL
"Mark Oliver" wrote:

> Hi,
> i FPTed my files to my host ISP. Now i can browse to
> www.mysite.com/WebForm1.aspx. The problem is that my ISP runs index.html
> at www.mysite.com. If i delete index.html i get "HTTP Error 403 -
> Forbidden" at www.mysite.com. How do i get www.mysite.com to display
> WebForm1.aspx?
> Thanks,
> Mark
>
>
renaming to index.aspx works great!
Thanks Bill and MikeL
Mark
"Mark Oliver" <camarkco@.hotmail.com> wrote in message
news:8bCdnaLdHKKcAQLcRVn-gg@.adelphia.com...
> Hi,
> i FPTed my files to my host ISP. Now i can browse to
> www.mysite.com/WebForm1.aspx. The problem is that my ISP runs index.html
> at www.mysite.com. If i delete index.html i get "HTTP Error 403 -
> Forbidden" at www.mysite.com. How do i get www.mysite.com to display
> WebForm1.aspx?
> Thanks,
> Mark
>
>

newbie - variable from code-behind to aspx page

Sorry for the question but I am a newbie of asp.net 2.0.
I have a variable in code behind and I would show it in aspx page (with
<% ... %> ).
How can I do it? or what is the best method for print db data in aspx page?
thanks
DamianoNormally you use controls and set their value programatically in codebehind.
Say
<asp:literal id="Name" runat="server" />
you could then do Name.Text = "SomeValue"
different controls fit different needs..the literal control shown above is
great for basic data.
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
"Damiano Callegari" <yamne.it@.NOSPAMgmail.com> wrote in message
news:%23geTK9UFGHA.2012@.TK2MSFTNGP14.phx.gbl...
> Sorry for the question but I am a newbie of asp.net 2.0.
> I have a variable in code behind and I would show it in aspx page (with <%
> ... %> ).
> How can I do it? or what is the best method for print db data in aspx
> page?
> thanks
> Damiano
well you newbe in general or only in 2.0?
Because i always use a label in the page and in the code behind page i
do label.Text = myDbVar
But you can use simple as Response.Write(myDbVar)
But if there is any special way to do this in 2.0 i dunno.
And also if you new at ASP.NET, you can always use <%%> but in general
there is a better solution for this using ASP.NET code behind.
And also if you new at ASP.NET, you may get about compiled
code and WYSIWYG compiled code have CODE BEHIND the other dont
New to 2.0 or to ASP.NET?
I dont know if 2.0 have any new on how to do this but you can always
use
Response.Write(yourVar);
<%%> also works but its a legacy from ASP

newbie - variable from code-behind to aspx page

Sorry for the question but I am a newbie of asp.net 2.0.
I have a variable in code behind and I would show it in aspx page (with
<% ... %>).
How can I do it? or what is the best method for print db data in aspx page?

thanks
DamianoNormally you use controls and set their value programatically in codebehind.

Say

<asp:literal id="Name" runat="server" /
you could then do Name.Text = "SomeValue"

different controls fit different needs..the literal control shown above is
great for basic data.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/

"Damiano Callegari" <yamne.it@.NOSPAMgmail.com> wrote in message
news:%23geTK9UFGHA.2012@.TK2MSFTNGP14.phx.gbl...
> Sorry for the question but I am a newbie of asp.net 2.0.
> I have a variable in code behind and I would show it in aspx page (with <%
> ... %>).
> How can I do it? or what is the best method for print db data in aspx
> page?
> thanks
> Damiano
well you newbe in general or only in 2.0?

Because i always use a label in the page and in the code behind page i
do label.Text = myDbVar

But you can use simple as Response.Write(myDbVar)

But if there is any special way to do this in 2.0 i dunno.

And also if you new at ASP.NET, you can always use <%%> but in general
there is a better solution for this using ASP.NET code behind.

And also if you new at ASP.NET, you may get confused about compiled
code and WYSIWYG compiled code have CODE BEHIND the other dont
New to 2.0 or to ASP.NET?

I dont know if 2.0 have any new on how to do this but you can always
use
Response.Write(yourVar);
<%%> also works but its a legacy from ASP

Newbie : aspx and javascript

Hello,
Is it possible to call an aspx page from an html page (via javascript)
and get some return value from the aspx? I want to get a string from
the aspx and add it to a div, something like :
myDiv.innerHTML += returnValueFromAspx;
Thanks in advance for the response.There are several ways, probably the easiest for a beginner is to use the
browser's built-in XMLHTTPRequest object, and get the string back in the
ResponseText proeperty. Then you just do
document.getElementById('myDiv').innerHTML= myXmlHttp.ResponseText;
Pete
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Bartlett" wrote:

> Hello,
> Is it possible to call an aspx page from an html page (via javascript)
> and get some return value from the aspx? I want to get a string from
> the aspx and add it to a div, something like :
> myDiv.innerHTML += returnValueFromAspx;
> Thanks in advance for the response.
>
Read this easy tutorial on Ajax
http://www.w3schools.com/ajax/default.asp
and check out the ajax section at
http://ajax.asp.net/default.aspx?tabid=47--
Regards
John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Bartlett" <stef_chr@.yahoo.fr> wrote in message
news:1164902904.001338.81740@.l12g2000cwl.googlegroups.com...
> Hello,
> Is it possible to call an aspx page from an html page (via javascript)
> and get some return value from the aspx? I want to get a string from
> the aspx and add it to a div, something like :
> myDiv.innerHTML += returnValueFromAspx;
> Thanks in advance for the response.
>

Newbie : aspx and javascript

Hello,

Is it possible to call an aspx page from an html page (via javascript)
and get some return value from the aspx? I want to get a string from
the aspx and add it to a div, something like :
myDiv.innerHTML += returnValueFromAspx;

Thanks in advance for the response.Read this easy tutorial on Ajax
http://www.w3schools.com/ajax/default.asp
and check out the ajax section at
http://ajax.asp.net/default.aspx?tabid=47--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Bartlett" <stef_chr@.yahoo.frwrote in message
news:1164902904.001338.81740@.l12g2000cwl.googlegro ups.com...

Quote:

Originally Posted by

Hello,
>
Is it possible to call an aspx page from an html page (via javascript)
and get some return value from the aspx? I want to get a string from
the aspx and add it to a div, something like :
myDiv.innerHTML += returnValueFromAspx;
>
Thanks in advance for the response.
>

Monday, March 26, 2012

newbie aspx.vb file question

I am brand new at building asp.net web sites. I am going through a site now that has some code behind links to aspx.vb files. I realize these files are compiled into dlls and used that way. But I am trying to find the aspx.vb files so I can review the actual code. Where are these files normally kept?

Thank you, in advance.

Jim

Hey Jim,

The *.vb files should be kept in the same directory as their corresponding *.aspx file. If the *.vb files don't exist in the same directory as the *.aspx files it is because a) the web site was pre-compiled and the code behind files are now packaged in a DLL as you mentioned or b) the code behind is inline in the *.aspx files (the code behind files do not have to be separated out into a separate file, they can be in the *.aspx file in a <script> block.)

Quick reference:

*.aspx files: Presentation Layer (HTML + ASP.NET controls)

*.vb or *.cs files : Codebehind files that go along with matchting *.aspx files (these are optional as code can be included in <script> blocks in the *.aspx pages.)

Hope that helps.

-Aaron

newbie class problem

Hi
Sorry to hassle you all again...

Still stuggling with classes. Heres the problem:

I have an aspx code with the following:


<%@dotnet.itags.org. Page Language="VB" src="http://pics.10026.com/?src=photogranny_connections.vb" inherits="Peter" %>
<script runat="server">
dim SQL as string = "SELECT * FROM [images] Order by ID asc"
dim Referrer as string ="OpenDS"
connectionStr(SQL,Referrer)
</script>
<html>...etc

and then I have the class as below


imports system
imports System.Data
imports System.Data.ODBC
imports System.Web.HttpContext
imports System.Web.UI.Page
imports system.web.UI

Public Class Peter
Inherits Page

Sub connectionStr(SQL as string,referrer as string)
-->logic here
End Sub

End Class

however, When I try and call the sub I get 'declaration expected'. Its referring to connectionStr. Its as if it can't see the sub. Iver tried making it a public sub but no joy. The .vb file is in the same directory as the other page.

Thanks for your help
PeterWhen you create a class, you must initialize an object of that class before using it.

MyClass obj = New MyClass
obj.MethodName1("...")

regards
thanks. is this the same for a codebehind file. If I just change the page directive to codebehind="filename" how then do I call the individual subs?

Thanks
Well its the same thing.

regards

Newbie current Page link Question

I everyone just wondering how i can pull out the current page link in the code behind page.

Ie say my website is:http://www.webpage.com/index.aspx

so say i am inside this page how do i extract the full link "http://www.webpage.com/index.aspx" to make it availabe to the page that is index.aspx

Hope i am making some sense

Kevin

Hi,

would Request.Urlhelp you?

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. :-)

Newbie help! importing custom namespaces in IIS

Hi say for example if I had the following code: - how would I instantiate testclass in an aspx page. I am aware that I have to Import Namespace="tester" but do I compile test.cs into a library? and if so where on the webserver do I store it, (is stored in wwwroot\bin\)?

//test.cs
using System;
namespace tester{
public class testclass {
public String myString;
public void setMystring(){
myString = "hello world";
}
public String getString(){
return myString;
}
}

}

You help would be appreciated!
Thanks
abzI assume you aren't using Visual Studio .NET

You answered your own questions:

compile the cs file:

cs /t:library testclass.cs

and put it in your application's bin directory.

Friday, March 16, 2012

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.
> --