Showing posts with label step. Show all posts
Showing posts with label step. Show all posts

Saturday, March 24, 2012

Strange Error - When Subfolder is converted to virutal folder

Let me explain step wise.
1.. I have a site running on port 5555
2.. If contains web.config file with contains <Forms> authentication.
3.. The site contains a sub-folder named "MembersArea" which contains ss.aspx
4.. ss.aspx contains page_load event which prints
Response.Write(Page.User.Identity.Name);
5.. Everything work proper untill here
6.. Now i want to have one more web.config file for folder "MembersArea" , I know i just cannot put web.config file into any sub-folder unless the folder is a "virtual folder"
7.. so i converted the "subfolder" into "virtual folder" from IIS Manager. (Note: I have not yet created any web.config in this subfolder)
8.. Now when i try to execute ss.aspx it throws strange error ... ( you can see the screen dump in the attached file)
9.. The Erorr message is: "Could not load type 'hs.ss'."
10.. When i remove the "virtual folder" it works again.
Can some one tell me what's actuall happening.When you set up another virtual folder, the ASP.NET runtime thinks that you
have an entirely separate ASP.NET application, and any data from the root
application is no longer available to you. In this case, your compiled code
is sitting in the root directory's bin subdirectory, and is not accessible
to the new application that you have created. Just leave it set up to not be
a virtual folder, and you will be fine. Also, you are absolutely able to
override settings in the web.config of your child folders - there are some
settings that are only held at the root level, these settings are inherited,
and you simply override those settings you need modified for a subfolder.
Most commonly, what I do is change access permissions for subfolders in a
child web.config, and leave everything else as the inherited values.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

<Jignesh> wrote in message news:OAA5puswDHA.1088@.tk2msftngp13.phx.gbl...
Let me explain step wise.
1.. I have a site running on port 5555
2.. If contains web.config file with contains <Forms> authentication.
3.. The site contains a sub-folder named "MembersArea" which contains
ss.aspx
4.. ss.aspx contains page_load event which prints
Response.Write(Page.User.Identity.Name);
5.. Everything work proper untill here
6.. Now i want to have one more web.config file for folder "MembersArea" ,
I know i just cannot put web.config file into any sub-folder unless the
folder is a "virtual folder"
7.. so i converted the "subfolder" into "virtual folder" from IIS
Manager. (Note: I have not yet created any web.config in this subfolder)
8.. Now when i try to execute ss.aspx it throws strange error ... ( you
can see the screen dump in the attached file)
9.. The Erorr message is: "Could not load type 'hs.ss'."
10.. When i remove the "virtual folder" it works again.
Can some one tell me what's actuall happening.
I have a situation as follows. please suggest what shall i do.
a.. To login into the main site users need passwords. Its simple i have done this using asp.net forms authentication method.
b.. The site has "admin" section. which is to be protected by one more password level. Even if the user tries to access any admin pages directly by typing in url it should ask user "special" password to access pages.
c.. I thought by making it virtual directory i will be able to add web.config file with <authentication> tags for this sub-virtual folder.
But now it seems it will not be possible to do this. can u tell me any other way to implement this?

Regards,

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message news:%23af0bfywDHA.3116@.tk2msftngp13.phx.gbl...
> When you set up another virtual folder, the ASP.NET runtime thinks that you
> have an entirely separate ASP.NET application, and any data from the root
> application is no longer available to you. In this case, your compiled code
> is sitting in the root directory's bin subdirectory, and is not accessible
> to the new application that you have created. Just leave it set up to not be
> a virtual folder, and you will be fine. Also, you are absolutely able to
> override settings in the web.config of your child folders - there are some
> settings that are only held at the root level, these settings are inherited,
> and you simply override those settings you need modified for a subfolder.
> Most commonly, what I do is change access permissions for subfolders in a
> child web.config, and leave everything else as the inherited values.
>
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
>
> <Jignesh> wrote in message news:OAA5puswDHA.1088@.tk2msftngp13.phx.gbl...
> Let me explain step wise.
> 1.. I have a site running on port 5555
> 2.. If contains web.config file with contains <Forms> authentication.
> 3.. The site contains a sub-folder named "MembersArea" which contains
> ss.aspx
> 4.. ss.aspx contains page_load event which prints
> Response.Write(Page.User.Identity.Name);
> 5.. Everything work proper untill here
> 6.. Now i want to have one more web.config file for folder "MembersArea" ,
> I know i just cannot put web.config file into any sub-folder unless the
> folder is a "virtual folder"
> 7.. so i converted the "subfolder" into "virtual folder" from IIS
> Manager. (Note: I have not yet created any web.config in this subfolder)
> 8.. Now when i try to execute ss.aspx it throws strange error ... ( you
> can see the screen dump in the attached file)
> 9.. The Erorr message is: "Could not load type 'hs.ss'."
> 10.. When i remove the "virtual folder" it works again.
> Can some one tell me what's actuall happening.
>
>

Strange Error when executing a function

in my code-behind i call a class method that returns a string value...
i run step by step and works great!!

but when i run without breakpoint... sometimes i get error because my string is empty...
and then i run again step by step... and the surprise! works fine again...

why is this happening??

this is my code-behind

string param = " ";

param +=ConfigurarLoja.RetParams( );

Session.Add("ssnHabItemVincPromo",param);

if(param == " ")

{

response.redirect("~/Erro.aspx");

}

And this is my class method:

publicstaticstring RetParams()

{

string param ="";

int cd_empresa =Convert.ToInt32(HttpContext.Current.Session["ssnCdEmpresa"]);

string sql ="SELECT TOP 1 * FROM LjConfig WHERE cd_empresa = " + cd_empresa +" AND ISNULL(DATEADD(dd, 01, dt_exclusao), GETDATE()) > GETDATE() ORDER BY dt_inclusao DESC";SqlConnection con =newSqlConnection(ConfigurationManager.ConnectionStrings["StringDeConexao"].ConnectionString);

con.Open();

SqlCommand cmd =newSqlCommand(sql, con);

SqlDataReader dr = cmd.ExecuteReader();

dr.Read();

if (dr.HasRows)

{

param ="-" + dr["cd_empresa"].ToString().Trim();

}

con.Close();

return param;

}

ops... it seems solved...
i change the sql command 'WHERE'... i think it was a problem with the GETDATE... now its working fine...

AND (ISNULL(DATEADD(dd, 01, dt_exclusao), DATEADD(dd, 01, GETDATE())) > GETDATE()) "

Strange execution,it is like not all lines are executed.

Hi,
I have this code and I have the impresion that all the lines are not exectuted it's like it jumps from line 10 to 14, even when I execute it step by step.
My oUserList Objects is equals nothing when I pass the mouse over it.
Sb has had this problem before?
The error I have is:
System.NullReferenceException: Object reference not set to an instance of an object.
(line 16)

Thanks


1 Public Class UserLendings
2 Inherits System.Web.UI.Page
3 Protected WithEvents DrlUser As System.Web.UI.WebControls.DropDownList
3 Protected WithEvents btnExec As System.Web.UI.WebControls.Button
5 Dim oUserList As New clsUserList()
6 Dim oUser As New clsUser()
7 Protected WithEvents grdProducts As System.Web.UI.WebControls.DataGrid
8 Dim cProductList As New Collection()
9 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
10 If Not IsPostBack Then 'Put user code to initialize the page here
11 DrlUser.DataSource = oUserList.GetAllUsers
12 DrlUser.DataValueField = "userid"
13 DrlUser.DataTextField = "userName"
14 DrlUser.DataBind()
15 DrlUser.SelectedIndex = 0
16 End If
17 End Sub

I have had something similar happen to me. If you are referencing this class from another project and you reference it from the obj folder ( like obj\debug ) rather than the bin folder and you have added code to the class, then you need to rebuild the class before you try to run the project that references the class. Otherwise, it will jump over the code that you have added since your last rebuild.

If you just hit F5 and have the system automatically rebuild the projects before running\debugging, you still have this problem. You have to manually tell the system to rebuild the class.

Hope this helps.
MajorCats

Tuesday, March 13, 2012

Strange problem setting focus on a TextBox within a WizardStep.

For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for the two steps,

TextBox1.Text ="foo";

and

TextBox2.Text = "bar";

Then in the first step the TextBox (TextBox1) contains the word foo and in
the second step the TextBox (TextBox2) contains the word bar. As you would
expect.

However if i replace the code with

TextBox1.Focus();

and

TextBox2.Focus();

Then i get the following error and i can't understand why. This is the
first time i have used Wizard controls and i'm just trying to work out how
they behave. What am i missing about Wizard controls that is causing this
behaviour.

A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: A form tag with
runat=server must exist on the Page to use SetFocus() or the Focus property.

Source Error:

Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
Line 20: {
Line 21: TextBox1.Focus();
Line 22:
Line 23: }

Source File:
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\M ultiViewTest.aspx.cs
Line: 21

Stack Trace:

[InvalidOperationException: A form tag with runat=server must exist on the
Page to use SetFocus() or the Focus property.]
System.Web.UI.Page.SetFocus(Control control) +2021658
System.Web.UI.Control.Focus() +20
Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\M ultiViewTest.aspx.cs:21
System.Web.UI.WebControls.View.OnActivate(EventArg s e) +105
System.Web.UI.WebControls.MultiView.set_ActiveView Index(Int32 value) +395
System.Web.UI.WebControls.MultiView.OnInit(EventAr gs e) +46
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
System.Web.UI.ControlCollection.Add(Control child) +146
System.Web.UI.WebControls.Wizard.CreateControlHier archy() +2992
System.Web.UI.WebControls.Wizard.CreateChildContro ls() +126
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692On further investigation it seems that i can't set the focus on any control
from within the activate event. I have no problems however, setting the
focus onto the textbox controls within the wizardsetps, from the Page_load
event

"clickon" wrote:

> For testing purposes i have got a 2 step WizardControl. Eqach step contains
> a text box, TextBox1 and TextBox2 respectively. If i put the following code
> in the respective activate event handlers for the two steps,
> TextBox1.Text ="foo";
> and
> TextBox2.Text = "bar";
> Then in the first step the TextBox (TextBox1) contains the word foo and in
> the second step the TextBox (TextBox2) contains the word bar. As you would
> expect.
> However if i replace the code with
> TextBox1.Focus();
> and
> TextBox2.Focus();
> Then i get the following error and i can't understand why. This is the
> first time i have used Wizard controls and i'm just trying to work out how
> they behave. What am i missing about Wizard controls that is causing this
> behaviour.
> A form tag with runat=server must exist on the Page to use SetFocus() or
> the Focus property.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information about
> the error and where it originated in the code.
> Exception Details: System.InvalidOperationException: A form tag with
> runat=server must exist on the Page to use SetFocus() or the Focus property.
> Source Error:
> Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
> Line 20: {
> Line 21: TextBox1.Focus();
> Line 22:
> Line 23: }
>
> Source File:
> E:\DevelopmentWebsite\IntranetDev\Portal\Testing\M ultiViewTest.aspx.cs
> Line: 21
> Stack Trace:
> [InvalidOperationException: A form tag with runat=server must exist on the
> Page to use SetFocus() or the Focus property.]
> System.Web.UI.Page.SetFocus(Control control) +2021658
> System.Web.UI.Control.Focus() +20
> Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
> E:\DevelopmentWebsite\IntranetDev\Portal\Testing\M ultiViewTest.aspx.cs:21
> System.Web.UI.WebControls.View.OnActivate(EventArg s e) +105
> System.Web.UI.WebControls.MultiView.set_ActiveView Index(Int32 value) +395
> System.Web.UI.WebControls.MultiView.OnInit(EventAr gs e) +46
> System.Web.UI.Control.InitRecursive(Control namingContainer) +321
> System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
> System.Web.UI.ControlCollection.Add(Control child) +146
> System.Web.UI.WebControls.Wizard.CreateControlHier archy() +2992
> System.Web.UI.WebControls.Wizard.CreateChildContro ls() +126
> System.Web.UI.Control.EnsureChildControls() +87
> System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
> System.Web.UI.Control.InitRecursive(Control namingContainer) +321
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692

Strange problem setting focus on a TextBox within a WizardStep.

For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for the two steps,
TextBox1.Text ="foo";
and
TextBox2.Text = "bar";
Then in the first step the TextBox (TextBox1) contains the word foo and in
the second step the TextBox (TextBox2) contains the word bar. As you would
expect.
However if i replace the code with
TextBox1.Focus();
and
TextBox2.Focus();
Then i get the following error and i can't understand why. This is the
first time i have used Wizard controls and i'm just trying to work out how
they behave. What am i missing about Wizard controls that is causing this
behaviour.
A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.InvalidOperationException: A form tag with
runat=server must exist on the Page to use SetFocus() or the Focus property.
Source Error:
Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
Line 20: {
Line 21: TextBox1.Focus();
Line 22:
Line 23: }
Source File:
E:\DevelopmentWebsite\IntranetDev\Portal
\Testing\MultiViewTest.aspx.cs
Line: 21
Stack Trace:
[InvalidOperationException: A form tag with runat=server must exist on the
Page to use SetFocus() or the Focus property.]
System.Web.UI.Page.SetFocus(Control control) +2021658
System.Web.UI.Control.Focus() +20
Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
E:\DevelopmentWebsite\IntranetDev\Portal
\Testing\MultiViewTest.aspx.cs:21
System.Web.UI.WebControls.View.OnActivate(EventArgs e) +105
System.Web.UI.WebControls.MultiView.set_ActiveViewIndex(Int32 value) +395
System.Web.UI.WebControls.MultiView.OnInit(EventArgs e) +46
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
System.Web.UI.ControlCollection.Add(Control child) +146
System.Web.UI.WebControls.Wizard.CreateControlHierarchy() +2992
System.Web.UI.WebControls.Wizard.CreateChildControls() +126
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692On further investigation it seems that i can't set the focus on any control
from within the activate event. I have no problems however, setting the
focus onto the textbox controls within the wizardsetps, from the Page_load
event
"clickon" wrote:

> For testing purposes i have got a 2 step WizardControl. Eqach step contai
ns
> a text box, TextBox1 and TextBox2 respectively. If i put the following co
de
> in the respective activate event handlers for the two steps,
> TextBox1.Text ="foo";
> and
> TextBox2.Text = "bar";
> Then in the first step the TextBox (TextBox1) contains the word foo and i
n
> the second step the TextBox (TextBox2) contains the word bar. As you woul
d
> expect.
> However if i replace the code with
> TextBox1.Focus();
> and
> TextBox2.Focus();
> Then i get the following error and i can't understand why. This is the
> first time i have used Wizard controls and i'm just trying to work out how
> they behave. What am i missing about Wizard controls that is causing this
> behaviour.
> A form tag with runat=server must exist on the Page to use SetFocus() or
> the Focus property.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information ab
out
> the error and where it originated in the code.
> Exception Details: System.InvalidOperationException: A form tag with
> runat=server must exist on the Page to use SetFocus() or the Focus propert
y.
> Source Error:
> Line 19: protected void WizardStep1_Activate(object sender, EventArgs
e)
> Line 20: {
> Line 21: TextBox1.Focus();
> Line 22:
> Line 23: }
>
> Source File:
> E:\DevelopmentWebsite\IntranetDev\Portal
\Testing\MultiViewTest.aspx.cs
> Line: 21
> Stack Trace:
> [InvalidOperationException: A form tag with runat=server must exist on the
> Page to use SetFocus() or the Focus property.]
> System.Web.UI.Page.SetFocus(Control control) +2021658
> System.Web.UI.Control.Focus() +20
> Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e)
in
> E:\DevelopmentWebsite\IntranetDev\Portal
\Testing\MultiViewTest.aspx.cs:21
> System.Web.UI.WebControls.View.OnActivate(EventArgs e) +105
> System.Web.UI.WebControls.MultiView.set_ActiveViewIndex(Int32 value) +3
95
> System.Web.UI.WebControls.MultiView.OnInit(EventArgs e) +46
> System.Web.UI.Control.InitRecursive(Control namingContainer) +321
> System.Web.UI.Control.AddedControl(Control control, Int32 index) +20652
79
> System.Web.UI.ControlCollection.Add(Control child) +146
> System.Web.UI.WebControls.Wizard.CreateControlHierarchy() +2992
> System.Web.UI.WebControls.Wizard.CreateChildControls() +126
> System.Web.UI.Control.EnsureChildControls() +87
> System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
> System.Web.UI.Control.InitRecursive(Control namingContainer) +321
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692
>