Advertisements
RSS

Category Archives: Programming

JavaScript: Cookies


A cookie is a variable that is stored on the user’s computer. You can use Javascript to create and retrieve cookie values.

To create a cookie:


function setCookie(sCookieName, sCookieValue)
{
var oCookieExpiryDate = null;
try
{
oCookieExpiryDate = new Date();
if (oCookieExpiryDate == null)
{
return -1;
}
oExpiryDate.setTime(oCookieExpiryDate.getTime() + (1000 * 60 * 60 * 24 * 30)); //30 days
document.cookie = sCookieName + "=" + sCookieValue + "; path=/" + ((oCookieExpiryDate == null) ? "" : "; expires=" + oCookieExpiryDate.toGMTString());
}
catch(e)
{
}
finally
{
}
}

To get the value of a cookie:


function getCookie (sCookieName)
{
try
{
var sCookieNameEQ = sCookieName + "=";
var oCookiesArray = document.cookie.split(';');
for(var i=0;i < oCookiesArray.length;i++)
{
var oCookieItem = oCookiesArray[i];
while (oCookiesArray.charAt(0)==' ')
{
oCookieItem = oCookieItem.substring(1,oCookieItem.length);
}
if (oCookieItem.indexOf(sCookieNameEQ) == 0)
{
return oCookieItem.substring(sCookieNameEQ.length,oCookieItem.length);
}
}
return null;
}
catch(e)
{
}
finally
{
}
}

 

Advertisements
 
Leave a comment

Posted by on October 10, 2012 in Programming

 

Tags: , , , , , , , , , , , ,

ReportViewer Error : Operation is not valid due to the current state of the object


I was getting this error in my ASP.NET application when I try to load a report into the report viewer control. To solve this I used the Reset() method of the report viewer control.



oReportViewer.Reset()
oReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote
oReportViewer.Visible = True
oReportViewer.ServerReport.ReportServerUrl = New System.Uri(sReportServiceURL)
oReportViewer.ServerReport.ReportPath = sReportName
oReportViewer.ShowParameterPrompts = False
oReportViewer.ShowDocumentMapButton = False
oReportViewer.DocumentMapWidth = 0
oReportViewer.ShowDocumentMapButton = False
oReportViewer.ShowFindControls = False
oReportViewer.ServerReport.Refresh()

 
Leave a comment

Posted by on September 27, 2012 in Programming

 

Tags: , , , , , , , , , ,

[XCode] Launch Google maps app


This code is to launch Google maps from an iPhone app and passing a longitude and latitude values:



NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%1.6f,%1.6f",56.152227,-9.162045];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];

 
Leave a comment

Posted by on June 3, 2012 in Programming

 

Tags: , , , , , , , ,

Updating Select Options using JQuery


So you implemented a webservice that return an ArrayList to update the Select Option.


Public Shared Function UpDateSelectList(ByVal sThemeID As String) As ArrayList


You can use the jQuery $.ajax to call the webservice


$.ajax({
type: "POST",
url: swebserviceURL,
data: oData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: jsGetArrayListSucess,
failure: function (response)
{
alert("An error was encountered");
}
});


In the callback function you need go through the array list to create an option item and add it to the Select Options


function jsGetArrayListSucess(response)
{
try
{
var DictionaryItems = response.d;
if (DictionaryItems == null || typeof (DictionaryItems) != "object") {
return;

}

var myDropDownList = $get('SelectList');
myDropDownList.options.length = 0;
myDropDownList.options[0] = new Option("Select ", 0);
for (var i = 0; i < DictionaryItems.length; ++i)
{
myDropDownList.options[myDropDownList.options.length] = new Option(DictionaryItems[i].Text, DictionaryItems[i].Value);
}

}
catch (err)
{

}
finally
{

}
}

 
Leave a comment

Posted by on March 3, 2011 in Programming

 

Tags: , , , , ,

VB.NET: Missing menu items in Visual Studio 2005

I noticed that some menu items are missing in Visual Studio 2005, I was mainly looking for the Build Menu Items

To fix this:

  • Click Tools, then click Import and Export Settings

  • In the Import and Export Settings Wizard, click Import selected environment settings, and click Next

  • Select Yes, save my current settings, then click Next

  • Select Visual Basic Development Settings, then click Next

  • Click Finish

  • The Import completed successfully

  • The Build menu looks much better now

 
1 Comment

Posted by on September 3, 2010 in Programming

 

Tags: , , , ,

Using Web.config in ASP

I used this code in ASP to read a web.config key value

set xmlDoc=server.CreateObject("Microsoft.XMLDOM")
set xmlappSettings=server.CreateObject("Microsoft.XMLDOM")
set xmladd=server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load(server.MapPath ("web.config"))
set xmlappSettings = xmldoc.GetElementsByTagName("appSettings").Item(0) 
set xmladd = xmlappSettings.GetElementsByTagName("add")
for each x in xmladd 
   ‘Check for the Atrribute Value
   if  x.getAttribute("key") ="RequiredKey" then
          sRequiredKey = x.getAttribute("value")
   end if
next

 
Leave a comment

Posted by on June 9, 2010 in Programming

 

Tags: , , , , , ,

Web Mobile Development

I was very busy recently working on a Web Mobile Application, The biggest problem I faced is detecting the Mobile screen size. eventually I used this .NET Mobile API.

I highly recommend 51degrees.mobi. Great support team

 
Leave a comment

Posted by on June 4, 2010 in Programming

 

Tags: , , , ,

 
%d bloggers like this: