Skip to main content

Posts

Showing posts with the label Asp.net

Featured post

XM Cloud content sync from prod to uat or UAT to prod step by step

When working with Sitecore, it’s common to need content synchronization across environments. Today, I’ll walk you through the steps to sync content from Production to UAT/TEST and vice versa. Steps to Follow 1. Set Up Your Workspace Create a folder on your computer where you will manage the script files and exported data. Open the folder path in PowerShell to begin scripting. We need to run some scripts in PowerShell to update the folder with the basic requirements for syncing content. PS C:\Soft\ContentSync> dotnet new tool-manifest PS C:\Soft\ContentSync> dotnet nuget add source -n Sitecore https://nuget.sitecore.com/resources/v3/index.json PS C:\Soft\ContentSync> dotnet tool install Sitecore.CLI PS C:\Soft\ContentSync> dotnet sitecore cloud login If the above error occurs, you will need to run a different command to resolve the issue. PS C:\Soft\ContentSync> dotnet sitecore init now, Again run above command to open and authenticate with XM Cloud. It will be there a...

How to use connection string in asp.net

Here, You may learn to create connection string in asp.net . Write this code into your code behind file. SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString()); Write thi code into your web config file. <appSettings>     <add key="ConnectionString" value="data source=shashi-pc; initial catalog=db_institute_newchanges;uid=sa;pwd=12345;" /> </appSettings>   

How to return data in array by using web method in c#

Here, I have created web method and used with ajax to get value .Here you can learn how to retun data in array and also created list of details class.     [WebMethod]     public static Details[] BindClass()     {         List<Details> Details = new List<Details>();         DataTable dt = new DataTable();         string Query = "select deptid, deptName from dept_master where Status=1";         using (SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString()))         {             using (SqlCommand cmd = new SqlCommand(Query, con))             {                 con.Open();                 SqlDataAdapter da = new SqlDataAdapter(cmd);     ...

How to create properties and use it with Generic class

Here, I have created properties in GetDetails class and use to get large amount of data which comes from database . see below code i have added lots of data in dataset make loop to add all data in list by help of properties . This is best to have good programmer. Follow this type of technique to get data. List<Details > Details = new List<Details >();          if (Ds.Tables[0].Rows.Count > 0)         {             foreach (DataRow dtrow in Ds.Tables[0].Rows)             {                 Details user = new GetDetails();                 user.RowNumber = dtrow["RowNumber"].ToString();                 user.Date = dtrow["Date"].ToString();                 user.FromTime = dtrow["FromTim...

How to use ajax and web method in asp.net

Here , I have created ajax method to call web service and after returning of data from web method i have bind that data into table for more details. please see  below code. $( '#submit ).click( function () {                                $.ajax({                     type: "POST" ,                     contentType: "application/json; charset=utf-8" ,                     url: "details.aspx/Struct" ,                     data: "{}" ,   ...

How to send mail in c# asp.net

Here, I have created method to send mail. Just call this method by passing suitable value in method . It will deliver at you send mail id. apply your email id and password to send mail.      public static string SendMail( string from= "" , string to= "" , string cc= "" , string bcc= "" , string subject= "" , string body= "" , string pass= "" , string host= "" )     {         string strret = "" ;         try         {             string username = from.ToString();             System.Net.Mail. MailMessage MyMailMessage = new System.Net.Mail. MailMessage ();             MyMailMessage.Subject = subject;          ...

How to bind data in grid using web method in asp.net

Here I have created method BindDataGrid () In this method I have used ajax method to get value from database by using web method . Web method return all the required data and bind it in table to form a grid for more details read the below code care fully. This is the web method which call through ajax. [ WebMethod]     public static ScheduleDetails[] BindGridByJs( string Status, string FromDate, string ToDate, string pagesize, string pageno, string Classname, string SubjectName, string TopicName)     {         DataSet Ds = new DataSet();         List<GetLectureScheduleDetails> Details = new List<GetLectureScheduleDetails>();         DataUtility Objdut = new DataUtility();         SqlParameter[] Param = new SqlParameter[10];         Param[0]...

How to get only numeric value in JQuery

See the below code which help you to get only numeric value in your text box. use it on keypress event on textbox             function onlyNumeric(event) {                 var charCode = (event.which) ? event.which : event.keyCode                 if ((charCode >= 97) && (charCode <= 122) || (charCode >= 65)                       && (charCode <= 90))                     return false;                 return true;             };

How to upload image in asp.net using file upload control

Here i am going to explain how to upload image on server. First add one file upload control on your page  and button give the suitable name of both file upload control and button control. Click on button control it will fire event on the name of button and it will redirect it to code behind file. It will also check the image content length and type of image Now see below code of code behind file. protected void Button1_Click( object sender, System. EventArgs e)     {         if (fu1.HasFile)         {             if (fu1.PostedFile.ContentLength <= 2097152)             {                 string fileexe = Path .GetExtension(fu1.FileName);        ...

How to add connection string in web config file

See the below which help you to create connection string in app setting of web config file in asp.net project or website and also some other example added in app setting key . < appSettings >     < add key = " ConnectionString " value = " data source=shashi-pc; initial   catalog=db_institute_newchanges;uid=sa;pwd=12345; " />     < add key = " MemberHeading " value = " Distributor " />     < add key = " ErrorMsg " value = " Error. " />     < add key = " InsertMsg " value = " Record Saved Successfully. " />     < add key = " ExistMsg " value = " Record Already Exist. " />     < add key = " DeleteMsg " value = " Record Deleted Successfully. " />     < add key = " UpdateMsg " value = " Record Updated Successfully. " />     < add key = " UndefineMs...

Login validate using asp.net

I have created a method name login and used sqlparameter to pass the loging using parameter in stored procedure and another one is click event of button . Click event call the login method by passing user input for login. Login method will validate through database and redirect it  to admin page.    protected void Login_Click( object sender, EventArgs e)     {         Login(UserName.Text.Trim(), Password.Text.Trim());     }     private void Login( string uid, string pas)     {         try         { private SqlParameter [] param; param = new SqlParameter [3];             param[0] = new SqlParameter ( "@username" , uid);             param[1] = new SqlParameter ( "...