Thursday, December 27, 2012

Use of Routing in Asp.net MVC


The basic thing we have to know when we working with MVC .i:e "How to deliver or processing a request in Asp.net MVC".we have dynamic object type  route ,which is used to manage requests.This can deliver request to web forms called web forms routing,wcf services or any other .But in MVC the it will directly send the request directly to controller.To exaplain this process i have choosen a basic Internet application .


In that you will go the App_Start folder ,then select the route config file.The routing file has default collection of mapRoute.Here we can also create our custom mapRoute as per requirement

Wednesday, December 26, 2012

how to create structure of database in sqlserver

Creating other database structure using existing data base using sqlserver is pretty simple compare to other.As you can see the below image ,the existing data base is appeared in sql server.In this example the existing  DB has 15 tables .Now i will place the same structure in to other DB.

To create structure we need to create a script for existing database.For this we have to select the generate script option.Then we can create script as in below


 
 To create a nee DB with this query we need to update the database name with desired DB name.Here i have changed to TestDB1.
                                      

 



Here you can observe the structure of the new database (TestDB1) which is complely similar to the structure of  existing one

Monday, December 24, 2012

methods of thread class in c sharp


Start():- it will start thread execution[Thread is ready for execution ]
Current Thread():- Shared method it will return thread under execution.
Sleep(milliseconds):-shared method iy will halt thread excution for perticular milliseconds
suspend():-It completly halt the thread execution
Resume():-It will state thread execution which is halted using suspend method
Abort():-It will stop thread execution[Killing thread execution]

Priority[property]:- t.Priority =thread Priority.High
                                 thread Priority.Abovenormal
                                 thread Priority.Normal[Default]
                                 thread Priority.BelowNormal
                                 thread Priority.Low
Priority will specify importance/weightage for thread.The thread with high priority will give more cpu cycle

Saturday, December 22, 2012

How to create one-Dimensional array in c#.net


This post will describe the basic concepts of chsarp which is array.
String [] str=new String[4];
In the above i have created two single dimensional array for integers and string.Here the str array size is 5.So we can create five elements from str[0] ...str[4]

Initialization of array:
int[] x=new int[] {1,2,3,4,5};
while initialization of array size is not recommended

Example:A program to print the default values of an array
Place a submit button on a form and add the below code
Button click event
{
int[] x= new int[2];
for(int i=0;i<x.lenght;i++)
{
MessageBox. Show(x[i]+..);
}
}

Thursday, December 20, 2012

Jquery Dropdownlist validation in asp.net

Title: JQuery How to validate Drop Down List value  in asp.net

Description:
Recently i have worked drop down list data validation using JQuery. Now i would like to explain how to validate the data of drop down list using JQuery .In previous articles i have given an example on Jquery drop down validation,JQuery allow only numbers.Here in this post i will given script for Validate DropdownList Using JQuery
Example:
   $(document).ready(function () {
    $('#btnsubmit').click(function(){
        cntydr = $('#ddlcountry');
        if (cntydr.length == 0 || $(cntydr).val() == "") {
            alert("Please Choose Country");
        }
        });
    });
As you can see the below screen shots to know the how they will get validation  conformation on page
In the above script i have used button click event to perform the validation.So when ever we click on the submit button the validations will be done.

Monday, December 17, 2012

Java Script Dropdownlist validation in asp.net

In previous post i have given Dropdownlist validation using jquery.In this post i will show how to perform validation on drop down list using java script in asp.net.Here we have to check whether the select index value of dropdown list is zero or not.Based on that we can do validation on it .
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropdownValidation.aspx.cs" Inherits="DropdownValidation" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Dropdown Validation using Jquery</title>
<script language="javascript" type="text/javascript">
function cityValidate() {
var ddlcity = document.getElementById("<%=ddlCity.ClientID %>");
if (ddlcity.selectedIndex <= 0) {
alert('please choose city');
return false;
}
else
return true;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table><tr><td>First Name:</td><td> <asp:TextBox ID="txtname" runat="server"></asp:TextBox></td></tr>
<tr><td>Last Name:</td><td><asp:TextBox ID="txtlastname" runat="server"></asp:TextBox></td></tr>
<tr><td>Phone:</td><td>  <asp:TextBox ID="txtaddr" runat="server"></asp:TextBox></td></tr>
<tr><td>City</td><td><asp:DropDownList ID="ddlCity" runat="server">
<asp:ListItem Text="Please Select" Value=""></asp:ListItem>
<asp:ListItem Text="Hyderabad" Value="a"></asp:ListItem>
<asp:ListItem Text="Delhi" Value="b"></asp:ListItem>
<asp:ListItem Text="Bombay" Value="c"></asp:ListItem>
<asp:ListItem Text="Chennai" Value="c"></asp:ListItem>
</asp:DropDownList></td></tr></table>
<asp:Button ID="btnvalidate" runat="server" text="submit"  OnClientClick="return cityValidate()"/>
</form>
</body>
</html>
Basic Form
Alert for Dropdown validation
Recently i have seen a question regarding dropdown lists.i:e which is correct in drop down or drop-down?. Every one would provide the answer with comment on this post

Sunday, December 16, 2012

Query to get the rank of student in a class in MYSQL

Based on my requiremnet i need to get the rank of student in million records in SQL database.Initially i just fetch the students records in decending order .Then put it an array in my code and got the result.This method will reduce the application performance.For this i have done complete data filteration in database using below query

SELECT sub_q.* , @rn := @rn + 1 'Rank_id'
FROM
(SELECT * FROM `student` ORDER BY total_marks DESC,DATE DESC) sub_q,(SELECT @rn := 0) r;
In the above query
1.Initialise the variable rn=0
2.The sub query given data of students records in sort order.
3.Here the rn will be incremneted based on the records count(@rn := @rn + 1).

Initial Data:
Existing Data of Database table
Resultant Data:
resultant output

Friday, December 14, 2012

How to set CSS properties only for IE9

Mostly this kind problem occur when working with different browsers.Recently i had struggle with css issue for my application.The problem here  is the image border has default border when load in IE but not in remaining browser.For this i just write CSS for IE browser.
#slider li img {border :none/9}
It can applied to applicaiton CSS when it will be loaded on IE

Tuesday, December 11, 2012

what is satellite assembly in asp.net


Assembly which contains only resources information is called as satellite assembly or "Resource only Assembly"
.net is providing Assembly linker utility (al.exe) to produced sattelite assembly

e:\vb.net al/embedresources my resources.resources/out:rassembly.dll
e:\vbnet92>dir r*.dll

It will produce raseembly.dll,this dll contains resources information.

Sattelite assembly exapmle

Monday, December 10, 2012

How to filter the data in Crystal report


Crystal Report viewer control is providing selection information property
Syntax:CRV.SelectionFormula="Criteria"

Here i will give some examples to filter the data in reports
Query based on numeric
CRV.SelectionFormula="{emp.deptno}=10"
Query based on string
CRV.SelectionFormula="{emp.nob}"="head"
Query based on date
CRV.SelectionFormula="{emp.expDate}"="#11/12/2012#"
We can use operators  >,<,in,like etc to filter the data.

Design of crystal reports

Title: Design of Crystal reports in asp.net

From VS 2008 to current version  providing the crystal report designer for generating reports towards windows form and web form.The applications should provide report generation to make data entry operator job easier.Report is formatted data with proper management.The info can be arranged in diffident section

*Report Header section:The info will be placed with in the first page of report
ex:Company name,logo,date etc
*Page Header Section :The information will be placed with in each page of report at the top
*Group Header Section:This will display grouped column information.It will avoid repetition
ex:display (deptno) only once
*Details section:It will display each record information
*Group footer section: Will display calculated value with respect to grouped columns
ex: sum of sals  w.r.t dept
* Page footer Section:The information will be displayed at the end of page.
ex:One out of count,turn page..etc
*Report footer Section:It will display information at the end of page.
total salary payed for all the emps

Thursday, December 6, 2012

How to remove or cancel onsubmit event in java script

This kind of situation we may get when we work with javascript methods.In my application the dynamic java script onsubmit event has been used to form for validation .Based on requirement i need to add the onclick event on submit button in form.So the problem here is ,when i click on the button the form onsubmit event also fired.Because of that i can't insert the valid data in to data base.
To resolve this i just do the onsubmit function return false.then then will stop that event when i click on button.
function validatecheck()
{
var rad=document.getElementById('OR');
if(radi.checked)
{
var vali=document.getElementById('OT').value;
if(val=="")
{
alert('Please enter value');
document.getElementById('frmres').onsubmit = function() {
return false;
}
}
else
{
document.getElementById('frmres').onsubmit = function() {
return dynamicvalidation();
}
}
}
}

Tuesday, December 4, 2012

Validate textbox based on radio button selection in java script

In this post i will show a simple validation on text box using java script base on radio box selection.Here i have radio button groups which has four radio button.Then the requirement here is ,when we checked the other radio button we should enter the data in to text box.To resolve this just given Id's to both controls and access to through the script.
HTML:
<div>
<table>
<tr>
<td><input type="radio" name="Amt_Num" value="1000"/></td><td>$2,000</td>
</tr>
<tr>
<td><input type="radio" name="Amt_Num" value="500"/></td><td>$300  </td>
</tr>
<tr>
<td><input type="radio" name="Amt_Num" value="450"  /></td><td>$250  </td>
</tr>
<tr>
<td><input type="radio" id="OtherR" name="Amt_Num" value="Other" />
</td><td>Other:</td><td><input type="text" id="OtherT"  name="AmtOther_Num" size="6"/></td>
</tr>
</table>
<input type="submit" id="btnsubmit" value="GetData" onclick="validatetext()"/>
</div>
 
JavaScript:

function validatetext() {
var v = document.getElementById('OtherR');
if (v.checked) {
var t = document.getElementById('OtherT').value;
if (t =="") {
alert('Please enter value in Other');
document.getElementById('OtherT').focus();
} 
}
}
In the above script ,just check the text box data is empty or not.If the text box is empty ,we will display an alert for confirmation.

Monday, December 3, 2012

How to get the data using onclick Event in java script ||Java script onclick event

In this post i would like give an example on Javascript onclick event and How to get the data of text box using java script.In the below one i will write down a onclick event for button ,then get the text box data in it.Here we can a method GetValue which has been using to get the data of input control.
<input type="text" id="txtname"/>
<input type="submit" onclick="GetValue()" value="GetData"/>

//Java script
<script type="text/javascript">
function GetValue() {
  var val=document.getElementById("txtname").value;
alert(val);
 }

</script>

Bel