Posts

Showing posts from 2012

Insert, Delete Rows, columns in HTML table Using Javascript

How to insert delete rows and cells dynamically in table using JavaScript Lets create a table object var table=document.CreateElement('table'); Or if you want to modify existing table then use below line. var table=document.getElementById('empTable'); you can set the attributes of table object using following code //Syntax object.setAttribute(attributeName, attributeValue); table.setAttribute("cellpadding","0"); table.setAttribute("cellspacing","0"); Now i want to add new row at the end, table, For this you need to get the Count of rows in table and Add the row at last index. var rows=table.getElementsByTagName('tr'); this will return the rows as array of object. Now insert new row at last index of table var lastIndex=rows.length; var newRow=table.insertRow(lastIndex); Now add the column to the newRow object. var cell=newRow.incertCell(0); Lets say i want to set inner HTML of this cell

Open source Social Networking site in Asp.net and Microsoft Ajax

Image
Open source Social Networking site in Asp.net and Microsoft Ajax If you want to develop Facebook like chat application in asp.net then don't go anywhere ChatME is open source best application to start with. Contain lots of functionality like message posting, chat box implementation, automatically loading pages using Ajax, Gallery management, Gallery sharing,  window.location.hash implementation to modify the URL of page without loading the page. There are so many other other advanced technique. Best part is that it is developed by only single developer within 1.5 month only. https://chatme.codeplex.com/ Contact me if you any some issue in setting this project in Visual Studio or setting database. tamarvijay@gmail.com

Step through the class while debugging in c#

You can use [DebuggerStepThroughAttribute] attribute before class declaration and this attribute instruct the debugger not to debug the code in this class. This is the best thing to hide your code while debugging. For more reference http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerstepthroughattribute.aspx

Best site to download ebooks of c# ,asp.net and sql server

this one is the best line to download c#,asp.net and Sql sever ebooks http://www.free-ebooks-download.org/free-ebook/

Create Thumbnail for large image in C# in 1 line of code

//import these file in you application using System.Drawing; new Bitmap("image to generate thumb").GetThumbnailImage(100, 100, null, IntPtr.Zero).Save("where to save image"); "image to generate thumb" is your Image path for which you want to generate thumbnail "where to save image" is the location with name of thumbnail

Get the cursor postion in Browser

<script language="javascript"> document.onmousemove=currMousePositionOnScreen; function currMousePositionOnScreen(event) { e = event || window.event; var x=e.pageX; var y=e.pageY; } </script>

Crop image using c#

   Bitmap bmpImage = (Bitmap)Bitmap.FromFile("Path Of image to crop ");  Bitmap bmpCrop = bmpImage.Clone(new Rectangle(left,top,right,bottom), bmpImage.PixelFormat);  bmpCrop.Save("path to save cropped image");  bmpCrop.Dispose();  bmpImage.Dispose();

Call Your javascript function of page load

<script type="text/javascript">      window.onload = PrintOnLoad; </script> <script type="text/javascript"> function PrintOnLoad(){    alert("Vijay Tamar"); } </script>
Call Asp.net Page Method Using Jquery  <html> <head runat="server">     <title>Ajax Page</title>     <script type="text/javascript" src="../Library/jquery-1.6.2.min.js"></script>     <script type="text/javascript" language="javascript">          function CalllPageMethod() { // this will be called on button click event                $.ajax({                 type: "POST",                 url: "Default.aspx/" + "GetData" , // Default.page is your page and GetData is Your public Method inside code behind file which will return some response.                 data: "{'FirstName': '"+$("input#txtFirstName").val()+"'} ",// Here i am passing the value of txtFirstname to GetData method //FirstName is parameter of GetData method                 contentType: "application/json; charset=utf-8" ,        
Dynamically change the value of public variable using reflection in c# Once i was working on asp.net project and i got a little task that i need to change the values of Blank public variables, i was having two way of doing this one was to set each variable value manually or other is by using reflection, i did little Google, and then created a method that replace the value of each public variable of type string. //this1 is the any class object and you want to replace the values of public string variables of this object public void ReplaceBlankValues(object this1) {   //MemberInfo  array will hold all public variables of class    MemberInfo[] properties = this1.GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance);             foreach (var property in properties)             {                 if (property.ToString().Length > 13)                 {                     string type = property.ToString().Substring(0, 13);                     if (type == &quo
Call Asp.net Page Method Without Microsoft Ajax, without j query Have you ever thought that we can call the web method without using j query, or Microsoft Ajax, This tutorial will help you lot to understand the Ajax in asp.net Default.aspx             <button onclick="javascript:callWebMethod();">             GetName</button> This button will call the callWebMethod() javascript method Default.aspx.cs Lets call GetName method using javascript       //I will call this method from client code using java script       [WebMethod]         public static string GetName(string name)         {             return "Hello " + name;         }  Javascript Code //name is the parameter in GetName Web method //vijay is the parameter value  var data = '{"name":"vijay"}';   // I will call this method on above button click event function callWebMethod() {     var xmlhttp = createXMLHTTPObject();     xmlhttp.onreadysta