Posts

Populate Dropdown with jquery using JSON request in asp.net mvc3

In this Article, I am going to demonstrate to fill the dropdownlist with J query using JSON in asp.net mvc3 . To achieve this task we need to write the following JavaScript code in view ( .cshtml page). @{ ViewBag.Title = "Products"; } <script type="text/javascript"> jquery(document).ready(function () { jquery("ddlCategory").change(function () { var idModel = jquery("#ddlCategory").val(); jquery.getJSON("product/items/", { category: idModel }, function (carData) { var select =jquery("#ddlitems"); select.empty(); select.append($('<option/>', { value: 0, text: "" })); jquery.each(carData, function (index, itemData) {

ASP.NET Redirect to open a new browser window using javascript window.Open method

To  redirect the page in new window there is no readymade methode in asp.net. To overcome this lack of readymade function, we need to do some custom coding and it will only achieve by using javascript Window.Open Methode. I have created the methode in c#.nnet to redirect the desired page in new window. Following is my methode defination.. public static void Redirect(string url, string target, string windowFeatures) { HttpContext context = HttpContext.Current; Page page = (Page)context.Handler; string script; if (!String.IsNullOrEmpty(windowFeatures)) { script = @"window.open(""{0}"", ""{1}"", ""{2}"");"; } else { script = @"window.open(""{0}"", ""{1}"");"; } script = String.Format(script, url

How to convert rows into columns in Sql Server 2008

Image
Convert rows into columns in sql server database? We're going to see how to do that using different query, and there is the "Pivot" function in SQL Server 2005.     Example: We are using two tables: Subject which is a lookup table that holds the subject names, and the StudentSubject which contains the student grades for the different subject. We are going to build the query having fixed columns: We can use the "case"  statement in the query to convert rows into columns. SELECT StudentId, SUM(Physics) AS Physics, SUM(Chemistry) As Chemistry, SUM(Math) AS Math, SUM(English) As English FROM (SELECT StudentId, (CASE SubjectId WHEN 24 THEN ISNULL(Grade, 0) END) AS Physics, (CASE SubjectId WHEN 25 THEN ISNULL(Grade, 0) END) AS Chemistry, (CASE SubjectId WHEN 26 THEN ISNULL(Grade, 0) END) As Math, (CASE SubjectId WHEN 28 THEN ISNULL(Grade, 0) END) AS English FROM Student_Subject) s GROUP BY StudentId Now, we can convert rows into columns

Highlight gridview row in update panel without posting back in asp net

When user selects particular row of gridview then that row should be highlighted. but in asp.net you do not have mechanism to to this task automatically. For this purpose you need to write some custom code, which includes some JavaScript code. to highlight the row selected by user follow the step below For this you have to write this code in your code behind file in OnRowCreated event or your can also write this code in OnRowDataBound event of grid... protected void ctlGridView_OnRowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", "onGridViewRowSelected('" + e.Row.RowIndex.ToString() + "')"); } } then add following script to your aspx page in script tag <script language="javascript" type="text/javascript"> var gridViewCtlId = '<%=ctlGridView.ClientID%>

Root your Gingerbread 2.3.4 android Mobile Phone

Root your Gingerbread 2.3.4 android Mobile Phone with following steps. before you start you have to download some files from here and follow the steps below  Put the phone in Debug Mode: Go to Settings > Applications > Development and check USB debugging box. Extract the files from the zip below, connect the phone via USB, and copy them to the phone via ADB like this: Code: adb push Superuser.apk /sdcard/Superuser.apk adb push su /sdcard/su adb push busybox /sdcard/busybox adb push exploit.bin /data/local/tmp/exploit.bin   Now we enter the phone's internal shell, also using ADB: Code: adb shell Then we take advantage of the "fake" root exploit: Code: cd /data/local/tmp chmod 0755 exploit.bin ./exploit.bin Now after that last command you should be back to your normal console, not the phone one, so we need to connect to it again, and doing so we should now see that we have root permissions since the "#" symbol is displayed

Proxy settings in android phone

Hi all, here i am going to demostrate about the proxy settings in android phone. As there is no UI for proxy settings for android web browser. But the android web browser will read the proxy settings in its settings database. Here is the instructions to enable the proxy in the android web browser. to do this setting you must download SDK package from android you need to check USB Debugging option in phones setting and follow the step given below > adb shell # sqlite3 /data/data/com.google.android.providers.settings/databases/settings.db sqlite> INSERT INTO system VALUES(99,’http_proxy’, ‘proxy:port’); sqlite>.exit You can talk to settings.db for more information. sqlite> SELECT * FROM system; sqlite> .tables sqlite> .databases sqlite> .schema table_name sqlite> more SQL expression to talk to the tables Don’t forget the ‘;’ at the end of the SQL expression.

How to get/find height and width of window using javascript

By knowing heigth and width of window we can place divs, messages,status wherever we want by using top left property of element. for that you should provide value of top and left to view in different monitors to get dynamic top left position you must find out the window width & height. following code will demostrate you to find out the window width & height which supports in  almost all browsers .   function windimension(){ if(window.innerHeight !==undefined) { var width= window.innerWidth; var height=window.innerHeight]; // most browsers } else{ // IE varieties var D= (document.body.clientWidth)? document.body: document.documentElement; var width= D.clientWidth; var height=D.clientHeight; } } Hope this will help u.......

Adding events to DOM Elements in javascript by For IE, Mozilla, Opera browsers

To add events to DOM element Dynamically using javascript needs to write different code for different browsers. Browsers Like Mozilla, Opera support the "W3C DOM Level 2 event binding mechanism"  which uses a function on DOM elements called addEventListener.  Following the way to  add events to DOM element Dynamically for all browser. if (window.addEventListener != null) { // Method for browsers that support addEventListener, e.g. Firefox, Opera, Safari window.addEventListener("focus", FocusFunction, true); window.addEventListener("blur", FocusLostFunction, true); } else { // e.g. Internet Explorer (also would work on Opera) window.attachEvent("onfocus", FocusFunction); document.attachEvent("onfocusout", FocusLostFunction); //focusout only works on document in IE }  Hope this will help you guys........

HTTP Error 500.21 - Internal Server Error - Simple Solution

HTTP Error 500.21 - Internal Server Error Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list. If you getting above error after publishing your asp.net application in IIS 7 then following is the simplest solution for you. Go to command prompt. Navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319 path. Then type aspnet_regiis.exe -i and hit enter. If you got message like "Asp.net installed suuccessfully" then you have done it then. Remember you must have administrator rights to do the above procedure .

Creation of Date Format function using javascript and Jquery

If you want to format the datetime string of database in your html file you need to get help from JavaScript.In javascript there is no pre define function exists to format date time string in dd MMM yyy. To accomplish the above task you need to write custom code. The following  is the custom function by using that you can format your date-time string in dd MMM yyyy format first you need to write array which has all months var gsMonthNames = new Array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ); Then add following function in html file function dFormat(date) { var result = ''; if (date != '') { var dateArray = date.split('/'); if (dateArray.length > 1) { result = dateArray[1] + " " + gsMonthNames[parseInt(dateArray[0])-1] + "