Posts

Drupal - Access denied. You are not authorized to access this page.

LEVEL : BEGINNER I recently read a post about 5 Top Drupal techniques and tried it on my site. I hid the login form from all users. To try the changes I made, I logged out from my drupal site. Disaster! I couldn't log back in and I was the super user! No matter which page I tried accessing, it threw the Access denied page. I tried the following: 1. Typed following urls to see if I can get the login form: http://localhost/drupal/ http://localhost/drupal/admin/ http://localhost/drupal/admin/login/ 2. Repaired Session table Steps followed: using phpmyadmin (http://localhost/phpmyadmin/) - navigate to drupal database and view the tables. select 'Session' table and scroll right down the page and select the dropdown which has 'With selected' option preselected. Select the 'Repair' option. This will rebuild your session table. 3. Cleared Session table. The above 3 did not work. Finally found the correct login page. http://localhost/...

Emerging technologies drummed up for 2010

Image
Gartner released report on Hype cycle for Emerging Technologies 2010. A mine-field of technologies for enterpreneurs who want to build their so called solutions (hardware and software) while people are still excited about it! I am betting on Cloud Computing/Web platforms along with Social Analytics to hit the plateau of productivity.

Windows 7 and GoToMyPC - Configure the Domain Group Policy to allow GoToMyPC to send Ctrl-Alt-Del

After installing Windows 7, I was unable to logon to the office computer using GoToMyPC. It came up with an error message along the lines of ‘The Domain Group Policy for this computer does not allow GoToMyPC to send Ctrl +Alt +Del. please contact your administrator'. I tried following the instructions given in the documentation of GotoMyPC's 'Pro Administrator Guide' till point 7, which read, I quote "Locate the Group Policy Object (GPO) in the domain or sub-domain that contains the policy that is preventing GoToMyPC from sending Ctrl-Alt-Del.". I spent some time looking for this policy but couldn't. I then started digging further into this issue and came across the concept of 'Secure Attention Sequence' which is basically a special sequence of events that enables a user to log on or off a computer, and how Windows Vista/Windows 7 introduced a new group policy setting which controls whether or not software can simulate a SAS. I solved my pr...

How to validate default values in a form ,- jquery validation plugin

I had a form which contained default values in the text boxes. ex: The first Name box has value 'Your Name' in it. But when onfocus, the text was cleared for user input. As I was using Jquery validation plugin i wanted to handle this scenario using jquery. Below is my question and the answer i came up with. http://stackoverflow.com/questions/2733922/jquery-validation-how-to-ignore-default-values-when-validating-mandatory-fields

jquery validation plugin and IE8 - 'jQuery.event.special.focusin' is null or not an object

I recently was using jquery validation plugin for form validation. It worked perfect on Firefox and Chrome. But when I tested on IE 8 , it did not work. The form submitted without any validation. using the inbuilt Javascript debugger for IE 8 (press F12 to activate it), I noticed the error 'jQuery.event.special.focusin' is null or not an object. I ran the sample that came with the jquery.validation plugin and it seemed to work on IE8 without any issues, the only thing I noticed was that the reference for jquery.js and the jquery.validation plugin were right below each other. So I did the same, I moved the jquery.js reference from master page to the page where the validation plugin was used and the validation worked fine! <script type="text/javascript" src="assets/scripts/jquery-1.2.6.min.js"></script> <script src="assets/scripts/jquery.validate.min.js" type="text/javascript"></script>

window.location does not work on Firefox

I had a scenario wherein a user clicks a button and a client side javascript function executes and redirects user to another page. I used window.location.href for redirection, but this did not work in firefox. Having looked up at other sites, the suggestion was to use window.location but this did not work still. I then realised that the problem was the way the javascript function was called in the onclick event of the button and it required a return false; to get it working. Below is the code sample, the button has a return false, which prevents the form from submitting to itself and enable re-direction. <script language="javascript" type="text/javascript"> function GoToRegistration() { var url = "http://www.lotussoftwaremall.com/" window.location=url; } </script> <input name="submit" type="image" src="submitbutton.png" onclick="GoToRegistration(); return false ;" width="80" he...

Technical Team Lead Interview Questions

Following are some of the questions which can be asked for a technical team lead interview: a. if you have a non performing developer in your team, how will you deal with them (Question relates to Motivation)? b. Have you ever had a project, that you were working on was in danger of missing the deadline and were you able to bring it back to schedule? if so how? c. Have you ever been part of recruiting members of the team? d. What document will you give to your developer when developing a requirement. State the details that will be included the document. e. What are your strengths and weaknesses? f. if we ask your team, what will your colleagues describe as your strengths and weaknesses.

Unable to add data connection.Could not load file or assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0,

Few days ago, I installed SQL Server 2005 on my Laptop. I opened up Visual Studio 2008 and tried to connect to SQL Server database. But, I got an error message: Unable to add data connection. Could not load file or assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. The solution for the above problem was to : Install the following from Microsoft SQL Server 2008 Feature Pack RC0, June 2008 - Microsoft SQL Server 2008 Native Client - Microsoft SQL Server System CLR Types - Microsoft SQL Server 2008 Management Objects if you do not have SQL 2008 then these features can be downloaded from: http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en#filelist After installing the components, close and reopen Visual Studio 2008, you should now be able to Add the database through your Server Explore...

Developer/Programmer interview practical test and solution

Below is a simple practical test which may be asked in interviews and the candidate may be expected to solve the problem within a duration of 40 to 45 mins . I have described the problem and given the solution for it. Question: A list of users and the manager they report to are available in the database. You need to display a). Count of all users who have a manager. b). Count of all users who do not have a manager. c). Display list of users and the managers they report to. Answer: When solving the problem , keep in mind the following: a. Design solution with clean architecture. - Properly layer your solution. Use separate project for data layer, business layer and presentation layer. Have a single solution file which combines all three project files. b. The test is for you to exhibit your problem solving/coding skills. Hence, avoid writing code which binds UI controls (ex: Dropdown,Repeater control) to DataSource controls(SQL, Xml or Object) . This will provide the required result, b...

AutoComplete using AutoCompleteExtender, JQuery and C# Web service

I implemented autocomplete functionality on one of my client website. Requirement: if user types in a location name incorrectly then the site is supposed to show a page which holds suggested names in radio button. The user selects one of the location and then clicks search, which will show a Search result page with properties relating to the location. The solution I offered was to use an auto suggest functionality which shows a list of suggested locations as and when the user types in the location textbox. This was agreed quickly since the time quoted was far less than the suggested requirement implementation and the UI would look 'very cool'... The solutions uses - AutoComplete Extender control (which is part of the Ajax Control Tool kit v3.5). - JQuery - perform ajax query to retrieve data. - Webservices written in C# to query the db and return results as JSON objects. I will publish the code sample.

NAnt development tips

Here are some Tips which might help you when debugging NAnt scripts. 1. Remember to update NAnt Framework tag if you are working with new version of .Net framework in Nant.exe.config file. I upgraded our system to .Net 3.5 and started coding. But when I checked in the files the nant build broke. I was racking my head for a while before I figured out that Nant was building for framework 2.0 and hence the new features which I coded against did not compile. 2. if you create new targets remember to add it in the 'depends' attribute of the 'build' target. I included a new component in my NAnt build script. I included the target for getting the latest file from sourcesafe and another target for building the file. When I ran the build script, it did not call the new targets. I figured out that I had not updated the 'depends' attribute of the build target task. Ex: 3. I use 'NantBuilder' tool which helped me in running specific targets and debugging it.

Navigate to another URL by pressing enter key

Problem : When I press enter , I want to navigate to another web page. I do not want to use form onsubmit event, as I am having the form tag on the master page. Solution: I have a form which has a search text box. The user enters the search keywords and presses enter. Below is the code (HTML rendering in this blog is awful, sorry about the illegible code) which does that Search A much more simpler implementation can be done using JQuery.

SQL Injection

Things to consider to avoid SQL Injection: 1. Have a function which vets the inputs from your forms :  ex: "select", "drop", ";" , "--", "insert", "delete", "xp_"  2. Escape single quotes with two single quotes ex: d'souza should be d''souza. 3. Set  size for number of characters text box can accept. Thus limiting the amount of untoward values that can be input 4. Do not use sa account for application related queries. Create a separate account with limited privleges. ex: if you need user to only view reports, create user account which has only 'SELECT' permissions.

Generics - List collection

// Generics example.  // Build a collection which accepts only a specific class type.  // ex: collection below accepts only cPerson namespace LearnOOp {    public class cGenericPersoncol     {         public string BuildGenericPersons()          {             cPerson cPer = new cPerson();             cPer.Name = "J Push";    //Create a List collection of type cPerson             List cPerColl = new List ();             cPerColl.Add(cPer); //// uncomment this line to test the collection. this should throw an error if you try passing //// a cMachine type class to the List collection created earlier.             //cMachine cMac = new cMachine();             //cMac.MachineName = "Matsumito";             //cPerColl.Add(cMac);             return cPerColl[0].Name;         }     }    // Person class     public class cPerson     {         string myName;         public string Name {             get { return myName; }             set { myName = value; }         } // Machi...

Search objects used in database

Below is the stored procedure which will query the database and find the list of objects which match the search string specified. CREATE PROCEDURE [dbo].[sp_Search_sProcs] @searchText varchar(100) AS SELECT sysobjects.name FROM sysobjects, syscomments WHERE syscomments.id = sysobjects.id and sysobjects.xtype = 'P' AND sysobjects.category = 0 AND syscomments.text LIKE '%' + @searchText +'%' ORDER BY sysobjects.name GO

Visual Studio debugger extremely slow

I was struggling with this problem for nearly a day and a half, before I found the solution. Hence, thought I will blog this. The website I was developing was running extremely slow when run under debugger of visual studio. Initially I thought, it may be the slowness of webservices or the database components that we were using. But passing the value through the interfaces produced results quickly. hence I concluded that the problem was with my local website code. The fix was elusive and time was running out. I began deleting the files in bin directory and recompiled the code. still same effect. I deleted the project .suo file and eureka! the project started running correctly!!! I read some where that deleting .ncb file may help aswell.. Happy Debugging : )

Dynamically setting classnames from style sheet

I was trying to find a way to dynamically set class name from stylesheet using javascript. many of the sites adviced to use obj.style.className==' ', but this did not work! instead use this : obj.className==' ' -- this work is IE and Firefox.

Calling a asp.net object from asp, returns Invalid procedure call or argument

I had to pass an object from asp to asp.net component but every time it returned an 'Invalid procedure call or argument:object name' I found that when passing objects from asp to .net components use the below method : oObject.Save(oObjectToBeSaved, errMsg) -- returned error message oObject.Save((oObjectToBeSaved), errMsg) -- works successfully. Also, the .net componenet which accepts parameters should have its signature set as ByRef..

Output content as excel and display File download box

Scenario: if you want to output some data as excel file, and display the File download dialog box, use the code below : Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment;filename= .xls"

How to change the default crusor type of recordset when executing a stored procedure?

Set the parameters in the following order: rs.CursorType =adOpenKeyset rs.CursorLocation=adUseClient rs.open , Opening a recordset in this manner will change the default connection from ForwardOnly to Keyset.