June 2006 - Posts - Developers Anonymous

June 2006 - Posts

I trying to find out exactly what happens on your page when you use an Atlas Update Panel.

The following script entries are made:

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
  <components>
    <pageRequestManager id="_PageRequestManager" updatePanelIDs="test" asyncPostbackControlIDs="test2,Button1" scriptManagerID="ScriptManager1" form="form1" />
  </components>
</page></script>

This is what is generated for the Update Panel. It automatically assigns an id to the PageRequestManager and the ID of the panel. It also shows which scriptmanager is being used and the id of the HTML form tag.

Then it adds the following:
asyncPostbackControlIDs="test2,Button1" which are triggers for my updatePanel. They are the IDs of two of my buttons on my form.

What I am trying to see is the webDesigner code which use to be generated in 2003. Because of the partial classes in 2005 it is no longer visible but there must be some way to access it. My guess says that MS are implementing ASP.Net2 CallBack function but I want to see where and how. another script is entered on the page:

<script src="/WebSite2005/WebResource.axd?d=awt4ucNHK2A73njJ46y3cYBEBjHFnMBe1p8c5-90bIB4jn5cMpKkIWszfip05MJ1Ad7IMJWD1_ttmg80Db0ixSk4Z1WE5dUBeK6GJ9ES53Q1&amp;t=632799165960000000" type="text/javascript"></script>

but I cannot find this file! I know the CallBack function uses Javascript code to be implemented. If anyone can show me how/where to access this code it would be appreciated.

I just want to find out exactly what is going behind atlas.

I think all I'm going to say is WOW.

I went to devDays yesterday and during the keynote Ahmed gave us a quick run through of ASP.Net ATLAS. And I cannot believe I've left it so long to get started on it. It is so easy. No jokes, it is amazingly simple!

I've already incorporated it into an existing application and it cause 0 problems. Best of all is the performance increase. So I'm going to show you have to use it really quickly.

1) Download ATLAS, its a 2.2MB file so I doubt the boss will mind ;)
    DOWNLOAD HERE

2) Reference the Microsoft.Atlas DLL

3) Check to see if the Atlas Tools are added to your toolbox, if not, then Right Click your Toolbox and Click Choose Items and just browse to the Atlas DLL.

now comes the fun part.

Drag and Drop the ScriptManager Tool onto your webpage. It'll create the following code,

<atlas:ScriptManager runat="server" ID="">

then all you do is set the following:
Set EnablePartialRendering="true"
Give the Update Panel an ID

your tag should look something like this now:
<atlas:ScriptManager runat="server" EnablePartialRendering="true" ID="updateManager">

Great, step one down.

Now, drag and drop the UpdatePanel onto your form.

It'll create the following code:

<atlas:UpdatePanel ID="" runat="server">
</atlas:UpdatePanel>

again, give it an ID then set its Mode to Conditional so your tag should look like this:

<atlas:UpdatePanel ID="atlasPanel" runat="server" RenderMode="Inline" Mode="Conditional">
</atlas:UpdatePanel>

Now then content for this panel must be entered as normal ASP.Net between ContentTemplate tags so it should look like this now:

<atlas:UpdatePanel ID="atlasPanel" runat="server" RenderMode="Inline" Mode="Conditional">
    <ContentTemplate>

    </ContentTemplate>
</atlas:UpdatePanel>

So for example, you have two drop downs in the Content Template. The first drop down being a set of countries and the second being a set of provinces.

<atlas:UpdatePanel ID="atlasPanel" runat="server" RenderMode="Inline" Mode="Conditional">
    <ContentTemplate>
          <asp:DropDownList ID="drpCountry" runat="server"
            DataTextField="DESCRIPTION" DataValueField="PK" AutoPostBack="True">
          </asp:DropDownList>

          <asp:DropDownList ID="drpProvince" runat="server"
            DataTextField="DESCRIPTION" DataValueField="PK" AutoPostBack="True">
          </asp:DropDownList>
    </ContentTemplate>
</atlas:UpdatePanel>

so when the user selects a differnt country the province drop down reloads. Now usually you'd have a postback to the server and the whole screen would reload. Not anymore. Simply select a different coutry now the provinces magically change without the postback.

The second part of the magic is, lets say you have a button of the form somewhere that reloads both dropdowns, all you need to do is add a trigger to the UpdatePanel as follows:

<atlas:UpdatePanel ID="atlasPanel" runat="server" RenderMode="Inline" Mode="Conditional">
    <ContentTemplate>
          <asp:DropDownList ID="drpCountry" runat="server"
            DataTextField="DESCRIPTION" DataValueField="PK" AutoPostBack="True">
          </asp:DropDownList>

          <asp:DropDownList ID="drpProvince" runat="server"
            DataTextField="DESCRIPTION" DataValueField="PK" AutoPostBack="True">
          </asp:DropDownList>
    </ContentTemplate>
<Triggers>
    <atlas:ControlEventTrigger ControlID="btnReload" EventName="Click" />
</Triggers>
</atlas:UpdatePanel>
  
and still no postback of the form!!!

Get started using ATLAS people, its fun, its free, its easy and besides, such a performance boost is bound to get you some brownie points from the boss and the clients!
Well, now that I've given a very very basic overview of Javascript and where the script tags are put we can move on.

As I said in my previous post, the <script> tag is put in head of your HTML document. There are also a few other places that you can enter javascript. If your default ClientSide script language is set to Javascript, you can enter javascript directly into HTML properties. Say for example you want to greet the user when the page loads:
<html>
    <head>
    </head>

    <body onload="alert('Hello');">

    </body>
</html>

this would popup a message box saying Hello.

The other place you can store your Javascript is in a .js file. This file is then included in your html by entering the following between your Head tags:

<script id="abc" src="relativePathHere" />

you can enter any id for the script but make it something useful like jsCommonFunctions. In the src property, enter the path to .js file relative to your project, e.g. ../Includes/Jscript/functions.js

What is nice about doing it this way is that should you feel the need to write tons of Javascript, it won't clutter up your html file.

I must say though, try not to write a 200 line function when that function can be broken up into 17 smaller functions that can be re-used. Javascript is an Object Orientated Language, so you can use that to your benefit.

Functions:

Javascript's syntax is very similar to C++, C#, and Java.

function fncTestFunction()
{
    alert('This function causes a popup');
}

that is the basic layout of Javascript function. Please note that Javascript IS CASE SENSITIVE!!! So be careful when naming your functions because fncTestFunction and fnctestfunction will be interpreted as two completely different functions. Going back to our earlier example:

<body onload="fncTestFunction()">

</body>

This is how we would can our new function. This will have the same effect as earlier, only the message in the box will be different. So now let's rewrite the function so that we can make it more useful.

function fncTestFunction(vUsrMessage)
{
    alert(vUsrMessage);
}

I have used the same function as before except I've added a parameter to the function. You can name your parameter anything you want. As you can see, I am just going to alert whatever is sent into the function, so our body code looks like this now:

<body onload="fncTestFunction('Hello')">

</body>

when you pass parameters into a function, the values must be surrounded by single quotation marks.

Thats it for now. Next time I'll deal with retrieving values from HTML controls and manipulating them.
http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html

The link above provides the complete ECMA Script binding for the Level 1 Document Object Model definitions. The page is broken up into HTML and Core DOM sections. For the HTML section will be the most useful, as it contains all the HTML controls and their properties.
Since I have been developing in ASP.Net full time since the beginning of this year I have decided to start writing some Javascript tutorials. My whole aim with this is to start getting more developers to use and understand Javascript.

I'm going to start off very simple.

Why would you want to use Javascripting?

That's easy, when a user see's something happen quickly on a webapp he/she immediately thinks the application runs faster than anything else they've used and once the user starts thinking that way, its good news for you as a developer. We all know that when an app is slow and the user is in a rush, it just frustrates them. Once they are frustrated you put up with their nonsense.

The other benefit of Javascripting is that you can control whether the page should post back or not. Client side validation is a beautiful thing! Once you move all your validation to Client side, things become quicker visually. You can create some pretty advanced Javascript validation.

Let's get started then:

Where to start?

Javascript code resides with <script> tags in your html. And the <script> tags reside within the <head> tag of your html page.

<html>
    <head>
        <script type='text/javascript'>
        <!--
            //Javascript goes here
        -->
        </script>
    </head>
   
    <body>

    </body>
</html>

the <script> tag has type property as you can see. There are many types of <script> variations in web development such as Javascript, CSS, and even our C# and VBScript. Now just within the script tags I start off with <!-- and end the block with -->, the reason behind that is that some very strange and outdated people are still using browsers that do not recognize Javascript and other scripting languages. When the browser encounters <!-- --> it treats the text within that as commented code and that way the application does not give an error.

For those of you coding in C# and the moment, you will catch onto Javascript very quickly as it is very similar to C#.

In my next installment I will show you have to write Javascript functions and implement them. I hope this little series will prove usefull to you.
http://www.fin24.co.za/articles/default/display_article.asp?Nav=ns&ArticleID=1518-24_1945641


Johannesburg - Telkom announced on Monday that it filed for a cut in ADSL rental of up to 32% and an overall price cut of 2.1% with the independent telecommunications authority Icasa.

Africa's biggest telecoms company said in a statement that the main beneficiaries of its proposed price changes will be ADSL users who will enjoy a reduction in rentals of up to 32%.

There are also reductions of up to 20% in the monthly rental for residential ISDN services, a decrease of up to 39% in the rates for IPLCs (International Private Leased Circuits) as well as significant cuts in long distance and international call charges.

The price changes will take effect on August 1 2006 if they are approved by the Independent Communication Authority of South Africa.

"Telkom is committed to its customer centricity drive and we are certain that the proposed price changes made to Icasa will result in significant savings for all our customers," said Steven Hayward, Telkom's Managing Executive for Retail Marketing.

"Although the net impact of the proposed prices will vary among customers, mainly due to the types of services they utilise, the overall effect will be a reduction in the cost of telecommunications in South Africa," he added.

No change in local calls Hayward said Telkom recently launched a range of calling plans for the consumer and business markets respectively under the Telkom Closer brand and Telkom SupremeCall brands.

"These packages substantially increase the value that customers derive and make considerable savings possible over and above our proposed price reductions," he said.-->

Despite inflationary pressures, local call charges remain unchanged. The minimum charge for local calls is 59.4 cents, with the per minute rates being 38c and 16c for Standard and Callmore Time respectively.

Callmore Time for national calls are from 19:00 to 07:00 (Monday to Friday) and from 19:00 on a Friday to 07:00 on Monday morning.

The price of long distance calls have been reduced by 10%. Long distance calls will now cost 72c per minute during Standard Time and 36c per minute during Callmore Time. The minimum charge for long distance calls have also dropped by 10% (8c) to 72c.

"Following two price reductions in long distance calls last year, our long distance call rates will now be even more competitive for both residential and business customers," stated Hayward.

Telkom customers with family or business ties to international destinations will benefit from a 9.9% reduction in the average price per minute of international calls.

Calls to the US will now cost at little as 99c per minute during Global Off-peak Time and R1.20 during Global Peak Time, while calls to UK will cost R1.30 and R1.40 during Global Off-Peak and Global Peak Times respectively.

International Global Off-peak Time is from 20:00 to 08:00 (Monday to Friday) and from 20:00 on a Friday to 08:00 on Monday morning.

Affordable DSL

In addition to these proposed price reductions, Hayward said that Telkom's price filing would also make DSL rentals "much more affordable".

The proposed DSL 192 and 384 monthly rental is R245 from August 1 2006 - a price decrease of R25 (9.3%) on the former and R114 (31.8%) on the latter. "We are combining our DSL 192 and DSL 384 services, and DSL 192 customers will automatically be upgraded in due course to an up-to 384kbit/s service, depending on network infrastructure.

"In future, business customers will also be able to subscribe to the DSL 384 service," explained Hayward.-->

There are also reductions of 24.1% on the monthly rentals for DSL 512 and DSL 1024. The proposed new monthly rental for DSL 512 is R362 (down from the current R477 monthly rental) while DSL 1024 monthly rentals are set to drop by R164 to R516.

The indicated DSL prices exclude ISP costs, line rental and call charges.

Some prices hiked

Hayward said in certain instances business considerations have dictated marginal price hikes.

He explained that minimum charges for local PrepaidFone calls are proposed to go up by 3c, while per minute rates are scheduled to increase by 2c (Standard Time) and 1c (Callmore Time).

PrepaidFone monthly line rental will remain unchanged.

While residential rentals for ISDN 2 and ISDN 2a lines will drop by R29.38 and R44.10 respectively, the monthly rental on post paid analogue lines will increase by R7.64 (residential) and R10.15 (business).

This year, the mandatory regulatory formula would have allowed Telkom to file a change in the price of its basket of products of -0.2%.

"That we have kept our increases well within these limits and have filed for an overall price decrease of 2.1% on our basket services, clearly demonstrates our on-going commitment to our customers as well as our determination to make telecommunications even more affordable and accessible," said Hayward.

"Having complied with regulatory prescriptions, Telkom is confident that our proposed price changes will be approved by Icasa," Hayward concluded. - I-Net Bridge

Just wish wish my girlfriend's sister congratulations. Her boyfriend propsed last night.

Here's to you and Anthony! Hope you guys will be happy together for a long time to come!!!