Saturday, January 29, 2011

How to config SMTP Server in web.config file

<system.net>
<mailSettings>
<smtp>
<network host="0.0.0.0" port="25" userName="yourusername" password="password"/>
</smtp>
</mailSettings>
</system.net>

Where to set up session timeout in asp.net web.config?

<configuration>
<system.web>
<sessionState timeout="20"></sessionState>
</system.web>
</configuration>
The default value is 20 minutes.

Detail:
http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.timeout.aspx

Friday, January 28, 2011

How to cancel Ajax call in JQuery?

By abort method in XMLHttpReuest.
Basically, ajax call in JQuery is a XMLHttpReuest.

Var currentcall = null;
currentcall = $.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
currentcall=null;
}
});

In other event handler, you can call currentcall.abort();

Reference:
http://www.w3.org/TR/XMLHttpRequest/#the-abort-method
http://api.jquery.com/jQuery.ajax/

Thursday, January 27, 2011

How to make enter key to cause postback in asp.net webform textbox by JQuery

How to make enter key to cause postback in asp.net webform textbox by JQuery

Need call doPostBack in asp.net webforms.
$('#<%=TextBox.ClientID %>').keypress(function (event) {
if (event.which == '13') {
__doPostBack('<%= TextBox.ClientID%>', '');
}
});

How to implement timer event handler in Javascript?

window.setInterval(yourfunction, 10000);
function yourfunction() { alert('test'); }