Sanjaya Web Designing

Sanjaya Web Designing
Sanjaya Web Designing

Saturday, June 18, 2011

Eleminating post backs with Ajax

On 15th October 2007 our undergraduate training period starts. I and another four our members select to hSenid (HBS) . They are Ruvindee (my girl friend), Sasanka, Dhinisha and Supunmalee.

I got the opportunity to work for project of “Sri Lanka Tea Board”. There my task is to remove all the post backs and implement ajax. So I start playing with atlas tool kit. But my supervisors (Mr.Champika and Mr.Dhanuja) asked me to use only ajax.dll. I was surprised after I saw the performance of ajax.

05/11/2007

Getting and Setting the value from a textbox

Today I had to edit a new form in my “Sri Lanka Tea board project”. After the weekend I have entirely fogeten syntax. So I made a foolish mistake when taking a value from a textbox. So this is the correct syntax for that.

var c=document.getElementById(“textboxname”).value;

If I have to enter a value the syntax is,

document.getElementById(“txtStudentName”).value = “Ruvi”;

Getting and Setting value from a label

I tried to apply same code to a label. But it did not work. Later I recognize there .value does not work. Instead of that we have to use innerText

the sysntax is as fallows.

var slbl=document.getElementById(“lblName”).innerText;

if you have to set a value in your label you should set the value like this,

document.getElementById(“lblName”).innerHTML = “Ruvi”;

Dealing with drop dwon list

In my application I have to get the index of the each item of the dropdwon. I was able to do that qouite easily by using ,

var> a=document.getElementById(“dropDwonListName”).selectedIndex;

but after that I had to take the value of the perticular item. So the syntax I use is,

var a=document.getElementById(“dropDwonListName”).selectedIndex; var year = document.getElementById(“drpYear”).options[a].text;

Now I have to run a function when the value of dropdwon change. So in the code behind I have write the function

dropDwonListName.Attributes.Add(“OnChange”, “return function();”)

If I am using a button instead of onChange() I have to use OnClick()

These are basic JavaScript operations with dropDwonList. Now I have to fill the dropDwon from a dataSet. It should happen in the page onLoad.

Response Redirect

Once the button click I have redirect the client to another form. In code behind I can do that easyly by using response.redirect(“formName.aspx”). But as I have to eliminate post backs I should use the fallowing syntax

window.open(“formName.aspx”how dataset fill a drop dwon

A dataset filling dropdwon

var dataset=StatisticSelectReport.GetAgroA(); var oSelect=document.getElementById(“drpAgro”);oSelect.options.length=0;for(var i = 0; i < dataset.value.Tables[0].Rows.length; i++){var oOption = document.createElement(“option”);oOption.value =’0′;oOption.innerHTML =dataset.value.Tables[0].Rows[i].Name;oSelect.appendChild(oOption);}Select or Deselect All check box list
function SelectRemoveAll(Select)
{
for (var n=0; n < document.forms[0].length; n++)
if (document.forms[0].elements[n].type==’checkbox’)
document.forms[0].elements[n].checked=Select;
return false;
}
in code behind
btnSelectAll.Attributes.Add(“OnClick”, “return SelectRemoveAll(true);return false;”)btnClearAll.Attributes.Add(“OnClick”, “return SelectRemoveAll(false);return false;”)Making a item read onlydocument.forms['Form1'].txtYear.setAttribute(‘readOnly’,'readonly’);Removing that attribute
document.forms['Form1'].txtYear.removeAttribute(‘readOnly’);selecting the dataset value to be visible in the dropdwon listfor(var i=0; i

functions to be visible true and false

function visibleFalse()//pass the objects for this function to be visible false{for(var i=0; iarguments[i].style.visibility=”hidden”;}

function visibleTrue()//pass the objects for this function to be visible True{for(var i=0; iarguments[i].style.visibility=”visible”;}elev()

it take string as script.

“2+2″=4

Professional Practices in AJAX

Hi during last few days I completed few forms of our “Sri Lanka Tea Boardg”. Now I am entertaining the beauty of ajax. Now my supervisor transfer me to deal with some serious forms. Now I understood with out proper professional practice it is difficult to engadge in serious stuff.

Exception handling

I do spelling mistakes since my early school days. The reason I feel shy is because I am still the same. So exception handling is a hevan for me. The syntax is,

try
{}
catch(err)
{}

I always use to get detail report throw

alert(err.description);

What is OLPC - One Laptop per child(OLPC)

One third of human in world suffer from poverty. In india ninety percent of people only contributing ten percent from the gross national product. But in the modern world the education try to over come this social discremination. On that technology and the intenet plays a major role. But with technology social face with digital devide. That is basically because most of the groups do not have money to buy a computer and to access the internat.

In this contest I see the project OLPC as the best social saervice project in this era. The project is initialted by Prof.Nickalas Negroponet who engage in Mesunset technical institute. His objective is to have a computer for each and every child in the world.

The special architecture enables to reduce the development cost to one hundrad dollers. The computer is okey for rough use as well. This does not contain a hard driver or a CD driver. The storage is IGB flash driver and the memory card is 256MB. The memory can increase by using SD memory card. to connect peripheral devices there are 4 ports. The processor is AMD Geode 433 Hz. This is suitable for low electricity consumption. In normal computers even there is no movement in screen the processor absorbs electricity but here it is differen. It works only when there is something shown in the screen. Also the Wi-FI adopter works with out connecting to the processor. Linux run on this system.

I assume early child hood education as the success of the any human being. Technology can play a big role in developing early child hood education. Currently OLPC project try to hand laptops for child free.

Sri Lanka is a developing country. Nearly 90% of Sri Lankans know how to wirte his name. The percentage is very happy compare to countries such as India. Our country has a big potential. So it is our responsibility to optimize our pre child education by utilizing these resources.

SET NOCOUNT ON

this is one line of code, put at the top of a stored procedure turns off the messages that SQL Server sends back to the client after each T-SQL statement is executed. This is performed for all SELECT, INSERT, UPDATE, and DELETE statements. Having this information is handy when you run a T-SQL statement in a query window, but when stored procedures are run there is no need for this information to be passed back to the client.

Alter procedure spSearchInqoury

@Code Varchar(50),
@ExecutiveName Varchar(50),
@SellingMark Varchar(50),
@OwnerName Varchar(50)
As

select c.CRMCustomerCode As CustomerCode,
ce.ExecutiveName As ExecutiveName,
Estate.SellingMark As SellingMark,
Owner.Name As OwnerName
from CRMCustomer c
inner join CustomerType ct On ct.CustomerTypeID=c.CustomerTypeID
inner join CRMCustomerExecutive ce On ce.CRMCustomerID=c.CRMCustomerID
inner join CustomerEstate cest On cest.CRMCustomerID=c.CRMCustomerID
inner join Estate On Estate.EstateID=cest.EstateID
inner join Owner On Owner.OwnerID=Estate.OwnerID
where

c.CRMCustomerCode like Replace(@Code,’All’,'%%’) OR c.CRMCustomerCode Like ‘%’+@Code+’%’ AND
ce.ExecutiveName like Replace(@ExecutiveName,’All’,'%%’) OR ce.ExecutiveName Like ‘%’+@ExecutiveName+’%’ AND
Estate.SellingMark like Replace(@SellingMark,’All’,'%%’) OR Estate.SellingMark Like ‘%’+@SellingMark+’%’ AND
Owner.Name like Replace(@OwnerName,’All’,'%%’) OR Owner.Name Like ‘%’+@OwnerName+’%’


Logical Operators

= Equal to

!= or

<> Not equal to

> Greater than

>= Greater than or equal to

< Less than

<= Less than or equal to

in Equal to any item in a list

not in Not equal to any item in a list

between Between two values, greater than or equal to one and less than or equal to the other not between

Not between two values

begins with Begins with specified value

contains Contains specified value

not contains Does not contain specified value

is null Is blank

is not null Is not blank

like Like a specified pattern. % means any series of characters. _ means any single character. not like

Not like a specified pattern. % means any series of characters. _ means many single character Department Table DepartmentID DepartmentName 31 Sales 33 Engineeri 34 Clerical 35 Marketing

SELECT Mark, count(*) as Countrows
FROM textreadercheck
GROUP BY Mark
HAVING count(*) > 1