Skip to main content

Posts

Showing posts from August, 2016

How To Count The Number Of Characters Occurrence In A String in Asp.net(C#).

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Programming.CharacterOccurence {     class Test     {         static void Main() {             String input = "Web Developer";             string ChartoFind = "r";             int totallengthofinput = input.Length;             int LengthOfInputWithOutCharToFind = input.Replace(ChartoFind, "").Length;             int resultcount = totallengthofinput - LengthOfInputWithOutCharToFind;             Console.WriteLine("Number of times occured the character r occured is : {0}", resultcount);             Console.ReadLine();         }     } }  

How To Reversing The Words In Sentence Using ASP.NET C#

Here I will explain how to reversing the words in sentence using Asp.net(C#) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Programming.ReverseWords {     class UsingReverseFunction {         static void Main() {             string input = "Nikhil Sangani is a Web Developer";             string output = string.Empty;             string[] wordsininput = input.Split(' ');             Array.Reverse(wordsininput);             output = string.Join(" ", wordsininput);             Console.WriteLine(output);             Console.ReadLine();         }     } }

How to bind data in jqgrid in Asp.net(C#)

Here I will explain how to bind data in jqgrid. First of all create a Table for save the data and then after stored procedure for retrive data from table. CREATE TABLE [dbo].[Student]( [StudentID] [int] IDENTITY(1,1) NOT NULL, [FirstName] [nvarchar](50) NULL, [LastName] [nvarchar](50) NULL, [Standard] [int] NULL, [Division] [nvarchar](5) NULL, [Address] [nvarchar](500) NULL, [Mobileno] [varchar](20) NULL, CONSTRAINT [PK__Student__32C52A795B736AEC] PRIMARY KEY CLUSTERED ( [StudentID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] CREATE PROCEDURE [dbo].[WB_Fill_StudentInfo] AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; SELECT * FROM Student ORDER BY StudentID END In this code snippest i will set cell color conditionally, Open fancybox popup, Display Image and also add checkbox s

How to get Session Value In A Static Method in Asp.net(c#).

We cannot use session in a static method. So i will show one way in which this can be done without much hassle. Just use the below syntax Using this code we can access the session value in static methods too. Create a website. Add a webform to it. Write the below code in the aspx page. <html xmlns="http://www.w3.org/1999/xhtml">   <head runat="server">         <title></title> </head>   <body> <form id="form1" runat="server">              <div>                  <asp:label id="lblsessionName" runat="server"></asp:label>             </div> </form> </body>   </html> We have a label on the page. We will assign a name to it using session in a static method. In the code behind file write the following syntax. using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.We

How to Pass value between pages using QueryString in Asp.net(C#)

Here I will explain how to pass value from one page to another page using Query String . We have two pages Default1.aspx page for pass the value and Default2.aspx for get the value from query string. Default1.aspx <html lang="en"> <head id="Head1" runat="server"> <title>SNJ Diam</title> </head> <body>     <form id="form1" runat="server">         <a href="Default2.aspx?Str=Nikhil">Home</a>     </form> </body> </html> Default2.aspx.cs  protected void Page_Load(object sender, EventArgs e)  {       if (!IsPostBack)       {            if (Request.QueryString["Str"] != null)            {                string Str = Request.QueryString["Str"].ToString(); //here we get value from Str string varriable "Nikhil"            }        } }

How to configure a cache expiration date for a Web site or application in Asp.net(C#)

Here I will explain how to configure a cache expiration date for a Web site or application  in Asp.net(C#). To Increse the performance of a website that is on IIs Server. Enable client side browser caching for static content (like for example images, CSS, JavaScript, jQuery) that was not change in near future. <configuration>    <system.webServer>   <staticContent>           <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMaxAge="12:00:00" cacheControlMode="UseExpires" />         </staticContent>    </system.webServer> </configuration>

How to download JSON string from url using web client and convert JSON to datatable in Asp.net(C#).

Here I will explain how to download JSON string from page url and how to set User-Agent in header. Also Convert JSON string into Datatable. string str = "type your json url here"; WebClient webClient = new WebClient(); if (webClient == null) {     webClient = new WebClient(); } else {     webClient.Dispose();     webClient = null;     webClient = new WebClient(); } DataTable JsonDataTable = new DataTable(); //Set Header webClient.Headers["User-Agent"] = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; //Download Content string JsonSting = webClient.DownloadString(str); //Convert JSON to Datatable JsonDataTable = (DataTable)JsonConvert.DeserializeObject(JsonSting, (typeof(DataTable))); JsonDataTable.TableName = "JSON_MAST";

Reading Response From URL in Asp.net(C#).

Here I will explain how to read response from url. This will read all the format like JSON, XML and any type of string. using System.Net; string str = "Here Type URL"; using (WebClient webClient = new System.Net.WebClient()) {    WebClient objWebClient = new WebClient();    var strcontent = objWebClient.DownloadString(str);    string valueOriginal = Convert.ToString(strcontent);    Console.WriteLine(strcontent); }