Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, March 26, 2012

Programming model question for Atlas apps

Hi,

I am designing a new web application and hope to leverage Atlas to make a better user experience than a regular ASP.NET web app. One of my things I hoping to archive to is to eliminate the need to have multiple ASPX pages.

Here is a scenario:

The web page may contain a left navigation panel that contains three links:

  1. Step 1
  2. Step 2
  3. Step 3

If I am to design a regular ASP.NET web app, I would make each of the links point to a separate ASPX page. Each of ASPX will share a common chrome such as header, top navigation panel and left navigation panel, but the main content area will be different. I would use a shared master page for them. The drawbacks of the traditional approach are:

  1. Opening each link will cause screen flickers
  2. There will be network delay from one step to another step that I can not reduce by preloading asynchronously.
  3. Each step will add to the browser history that my designer does not like.

I am hoping that Atlas will allow me to collapse all these ASPX pages into a single ASPX page, but I could not find a good approach. Specifically, I didn't find UpdatePanel useful for my design.

I am very interested to hear suggestions on how to archive my design objective. Thanks in advance.

Wei Zhu

hello.

well, you can use atlas to do this, though i really think that eliminating the history may not be a good thing. for instance, when i go to a web site, i really enjoy using the next and back buttons...and regarding to the delay, i really don't think that a normal asp.net page that has been modified to use atlas will be quicker that a traditional page.


Hi Luis,

Can you tell me how to use Atlas to achive my objective?

Regarding whether it is wise to eliminating IE history, I guess some people like it and some people don'tSmile [:)]. I personally don't have a strong opinion on either. As for the network delay, my thought is that using Atlas, maybe I can preload the UI for the step 2 asyncroulsy while user is still on step 1. However, reducing delay is more of an extra bonus credit, not a requirement.


Wei Zhu,

A simple approach to accomplish what I have interpreted your requirements is this:

Your left navigation could be setup as LinkButton controls.

You could put all 3 "pages" of content into a MultiView control.

On the postback of each LinkButton control, you could dynamically show and initialize all controls on the corresponding "View" of the MultiView control.

Surround all of these controls with an UpdatePanel and the result should be a page that appears to work completely clientside using the Atlas framework.

Hope this helps.

Ryan


Thanks Ryan.

I have considered using MultiView inside an UpdatePanel, but I think it will run into the following problems.

1. If I use Validators in each view, then switch view will cause a postback and the validators on those views that haven't been viewed will raise errors and prevent the postbacks from even happening.

2. This approach does not appear to be scale well as the number of views increase.


OK, I may have found a solution. The solution basically is to create a ASCX user control for each view, then load each user control dynamically using Page.LoadControl() inside a UpdatePanel. I did a quick test and it seems to work, although I still need to try it more.

This solution still does not address how to preload next view. It feel like possible to me, but I don't know exactly how to do it yet.


Have you considered using a Wizard control inside an update panel?

Programming Validators

I have the following by it doesnt seem to catch the errors;

HTML:

<input id="textBox" /> <span id="textBoxVa" style="color: red">* </span
function pageLoad(){

var textBox = new Sys.UI.TextBox($('textBox'));
textBox.initialize();

var requiredValidator = new Sys.UI.RangeValidator();
requiredValidator.set_lowerBound (5);
requiredValidator.set_upperBound (15);
requiredValidator.set_dataContext(textBox);
requiredValidator.set_errorMessage("ERROR WITH INPUT");
requiredValidator.initialize();

varvalidationLabel = new Sys.UI.ValidationErrorLabel($('textBoxVa'));
validationLabel.set_associatedControl(textBox);
validationLabel.initialize();
}

If I enter 0 or 1000, it doesnt seem to show my little red dot :(I think you need to call setOwner on the validator to associate it with the textBox.
Thanks for the response.

I thought that was the problem originally but:

var textBox = new Sys.UI.TextBox($('textBox'));
textBox.set_text("HELLO");
textBox.initialize();

var requiredValidator = new Sys.UI.RangeValidator();
requiredValidator.set_lowerBound (5);
requiredValidator.set_upperBound (15);
requiredValidator.set_dataContext(textBox);
requiredValidator.set_errorMessage("ERROR WITH INPUT");
requiredValidator.setOwner(textBox);
requiredValidator.initialize();

varvalidationLabel = new Sys.UI.ValidationErrorLabel($('textBoxVa'));
validationLabel.set_associatedControl(textBox);
validationLabel.initialize();

alert(textBox.get_isInvalid ());

Still does not work :(

Right. My mistake. You need to add the validator to the textbox's validators collection. This should take care of calling setOwner so you don't need to do it.


Thanks Bleroy :)

Final code sniplet:

var textBox = new Sys.UI.TextBox($('textBox'));
textBox.set_text("HELLO");
textBox.initialize();

var requiredValidator = new Sys.UI.RangeValidator();
requiredValidator.set_lowerBound (5);
requiredValidator.set_upperBound (15);
requiredValidator.set_dataContext(textBox);
requiredValidator.set_errorMessage("ERROR WITH INPUT");
requiredValidator.initialize();

textBoxValidator = textBox.get_validators();
textBoxValidator.add(requiredValidator);
Alright a couple more questions that I ran into:

1) I dont really have a clue as to setting up a custom Validator
2) Same thing with setting up Group Validators

I'm not getting the display to show up for the validation label. The alert shows it's invalid, but nothing displays.

var

textBox;function pageLoad()

{

textBox =

new Sys.UI.TextBox($('textBox'));

textBox.initialize();

textBox.set_text(1);

var rangeValidator =new Sys.UI.RangeValidator();

rangeValidator.set_lowerBound(5);

rangeValidator.set_upperBound(15);

rangeValidator.set_dataContext(textBox);

rangeValidator.set_errorMessage(

"Must be between 5 and 15");

rangeValidator.initialize();

var textBoxValidator = textBox.get_validators();

textBoxValidator.add(rangeValidator);

var validationLabel =new Sys.UI.ValidationErrorLabel($('textBoxVa'));

validationLabel.set_associatedControl(textBox);

validationLabel.initialize();

alert(textBox.get_isInvalid());

}


It is a mouseover tooltip kinda thing ;)

Saturday, March 24, 2012

Pulling my hair out over System.web.Extensions

I am new to this board so do all please be kind!

I have being programming with ASP for sometime, recently moving to ASP.net. I use Visual Web Developer 2005 (the one downloadable from MS)

I am getting the following error:

CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'System.Web' (are
you missing an assembly reference?)

I have definetly installed the AJAX extensions correctly as when I create a VB page as per the demonstration of adding the time reference, clicking a button to update the label on the page, etc, it works.

However if I switch to an application using a webservice, calling SQL server and using AJAX, I get the error. More information as follows:

Line 1: using System;
Line 2: using System.Web;
Line 3: using System.Web.Extensions; <LINE GIVING ERROR>
Line 4: using System.Web.Services;
Line 5: using System.Web.Services.Protocols;

c:\windows\system32\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library
/utf8output
/R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll"
/R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions.Design\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.Design.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll"
/R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll"
/R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll"
/out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\ws\69af2fc2\64a4ae07\App_Code.dopzyacv.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\ws\69af2fc2\64a4ae07\App_Code.dopzyacv.0.cs"
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\ws\69af2fc2\64a4ae07\App_Code.dopzyacv.1.cs"
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\ws\69af2fc2\64a4ae07\App_Code.dopzyacv.2.cs"

Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

~\App_Code\EmployeeService.cs(3,18): error CS0234: The type or namespace name
'Extensions' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
~\App_Code\Employees.cs(4,18): error CS0234: The type or namespace name 'Extensions'
does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

Where is it all going wrong!!!

Any help greatly appreciated!

Sorry if it doesnt, but does this post help? I remember reading it the other week :)

http://forums.asp.net/thread/1547872.aspx


A guy was having a similar issue on a hosted server :)

Cheers,

bobdeveaux


Hi,

I looked at the post after extensive searching of the forum before I decided to post myself.

I cannot see how that solution would work as the compiler seems to be finding System.Web.Extensions in the GAC - it's more a case of when it compiles the code it doesn't seem to like what it is reading!

I created the project in Visual Developer like I originally said. The project doesn't create a 'bin' directory only and 'App_code' one - I have tried creating a bin directory alongside 'App_code' and referencing what I had pasted into that however no joy.

Is it siginificant that the compiler seems to like the web.config file yet the two code files where it find using system.web.extensions throws it?