/    Sign up×
Community /Pin to ProfileBookmark

javascript after postback…

i have this 3 text box

txtStartTime, txtEndTime, and totalTime

using the attributes.add method i added javascripts on the onblur event of the txtStartTime and txtEndTime…

the javascript function will call a webservice which takes on as parameter the value of the control… it will then be processed and returns a value…

this works fine after i first started my webapps… after a postback… the javascript dont seem to work anymore…

i tried debugging and found out that it wont go to the javascript function…

need some help… a bit amazed why this happened…

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangOct 18.2007 — We can't help without code ...
Copy linkTweet thisAlerts:
@krispaksauthorOct 18.2007 — Dim sb As New StringBuilder

sb.AppendLine("var rootPath = location.href.substring(0, location.href.lastIndexOf('/'));")
sb.Append("var oValidateURL = ")
sb.AppendLine("rootPath + '/Webservices/Validations.asmx/CheckTime';")


sb.Append("var oQuickInfoURL = ")
sb.AppendLine("rootPath + '/Webservices/Quickinfos.asmx/GetJobAddress';")


Me.ClientScript.RegisterClientScriptBlock(Me.Page.GetType(), "rules2", sb.ToString(), True)
Me.ClientScript.RegisterClientScriptInclude("rules", "scripts/timesheetentry.js")

'overrides server events to implement client script
Dim stTB As TextBox = CType(Me.FormView1.FindControl("TsStartTimeTextBox"), TextBox)
stTB.Attributes.Add("onblur", "javascript:timevalidation_OnBlur();")
Dim stEB As TextBox = CType(Me.FormView1.FindControl("TsEndTimeTextBox"), TextBox)
stEB.Attributes.Add("onblur", "javascript:timevalidation_OnBlur();")


----code above is inside Page_Load - it adds attributes to the onblur event of the controls controls

--- javascript function--------

function timevalidation_OnBlur() {

var stime = document.getElementById('ctl00$LatitudeContentPlaceHolder$FormView1$TsStartTimeTextBox');
var etime = document.getElementById('ctl00$LatitudeContentPlaceHolder$FormView1$TsEndTimeTextBox');

var stimeval = stime.value;
var etimeval = etime.value;

oAjax = new ActiveXObject('Microsoft.XMLHTTP');
oAjax.onreadystatechange = ProcessResponseTimeValidation;
oAjax.open("POST",oValidateURL);
oAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oAjax.send("start=" + stimeval + "&end=" + etimeval);

return;

}

function ProcessResponseTimeValidation() {

if (oAjax.readyState == 4) {
if (oAjax.status == 200) {
var h = document.getElementById("ctl00$LatitudeContentPlaceHolder$FormView1$TsWorkedHours");
var de = oAjax.ResponseXML;
var sp = document.getElementById('ctl00_LatitudeContentPlaceHolder_FormView1_valTime');

if (de.text.charAt(0)== 'E')
{
sp.innerText = de.text.substring(1);
}
else
{
h.value = de.text;
sp.innerText = '';
} // if (de.text.charAt(0) == 'E')
} // if (oAjax.readyState == 4)
else
{
var sp = document.getElementById('ctl00_LatitudeContentPlaceHolder_FormView1_valTime');
sp.innerText = 'Problem in calling validation rules.';
} // if (oAjax.status == 200)
}

}

--- javascript function--------

the controls are inside a formview... and the set up is inside a master page.
×

Success!

Help @krispaks spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...