Wednesday, June 30, 2010

DNN programmatically login user

PortalSettings currentPortal = PortalController.GetCurrentPortalSettings();

UserLoginStatus loginStatus = new UserLoginStatus();

UserInfo objUser = UserController.ValidateUser(
currentPortal.PortalId,
ConfigurationSettings.AppSettings["DnnLoginUser"],
ConfigurationSettings.AppSettings["DnnLoginPassword"],
"DNN", "",
currentPortal.PortalName, HttpContext.Current.Request.UserHostAddress, ref loginStatus);

if (loginStatus == UserLoginStatus.LOGIN_SUCCESS)
{
UserController.UserLogin
(currentPortal.PortalId,
objUser, currentPortal.PortalName,
HttpContext.Current.Request.UserHostAddress, false);
}

Monday, June 28, 2010

disable enter key

<asp:TextBox onKeyPress="return disableEnterKey(event)" runat="server" name="txtUserName" ID="txtUserName" MaxLength="20" Width="135px"></asp:TextBox>

function disableEnterKey(e) {
var key;
if (window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
return (key != 13);
}

Monday, June 14, 2010

Setup Ubuntu as web server

http://www.securenetwork.it/ricerca/whitepaper/download/Debian-Ubuntu_hardening_guide.pdf

SELinux for Ubuntu Server:
http://selinuxproject.org/files/2008_selinux_developer_summit/2008_summit_brindle_ubuntu.pdf

The installation is as simple as:
Sudo apt-get install selinux

SELinux disables AppArmour

Wednesday, June 2, 2010

POST in asp.NET page without nesting forms

if (!IsPostBack)
{
ScriptManager.RegisterStartupScript(Page, this.GetType(), "postback", "function doExternalPost(targetUrl) { theForm.__VIEWSTATE.value = ''; theForm.encoding = 'application/x-www-form-urlencoded'; theForm.action = targetUrl; theForm.submit(); }", true);
}

litText.Text = string.Format("<input name="postInfo" value="{0}" type="hidden"><a onclick="\"javascript:doExternalPost('{1}');\"">clickme</a>", "prodABC" , "postURL");

Tuesday, June 1, 2010

reference jQuery in Visual Studio

<%if (false) { %>

<script language="javascript" type="text/javascript" src="../../Resources/Shared/scripts/jquery/jquery-1.4.2.js"></script>

<script language="javascript" type="text/javascript" src="../../Resources/Shared/scripts/jquery/jquery-1.4.2-vsdoc.js"></script>

<%} %>

<script language="javascript" type="text/javascript"><br /><br /> $(document).ready(function() {<br /><br /> });<br /><br /></script>