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 behindbtnSelectAll.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 attributedocument.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; i
function visibleTrue()//pass the objects for this function to be visible True{for(var i=0; i
it take string as script.
“2+2″=4