Saturday, 30 November 2019

How to delete file from folder in asp.net

How to delete any file form the folder



protected void btnDelete_Click(object sender, EventArgs e)
{
      
string file_name = yourfilename;
      
string path = Server.MapPath("files//" + file_name);
      
FileInfo file = new FileInfo(path);
      
if (file.Exists)//check file exsit or not      {
           file.Delete();
           lbl_output.Text = file_name + 
" file deleted successfully";
           lbl_output.ForeColor = 
Color.Green;
      }
      
else      {
           lbl_output.Text = file_name + 
" This file does not exists ";
           lbl_output.ForeColor = 
Color.Red;
      }
}
 I hope this will help you

Friday, 29 November 2019

How to get month,day and year from birth date

How to get month,day and year from birth date


Use this

   string birthDate = "2015/02/01";
   var split = birthDate.Split('/');
    If you get birthDate from database as datetime, you can extract date parts from it like:

    DateTime birthDate = DateTime.Now.Date;

    var year = birthDate.Year;
    var month = birthDate.Month;
    var day = birthDate.Day;

I hope this may help you

Wednesday, 27 November 2019

How to create setup in asp C#

How to create setup in asp C#



Use Visual Studio Setup project. Setup project can automatically include .NET framework setup in your installation package:
Here is my step-by-step for windows forms application:
  1. Create setup project. You can use Setup Wizard.
    enter image description here
  2. Select project type.
    enter image description here
  3. Select output.
    enter image description here
  4. Hit Finish.
  5. Open setup project properties.
    enter image description here
  6. Chose to include .NET framework.
    enter image description here
  7. Build setup project
  8. Check output
    enter image description here

Note: The Visual Studio Installer projects are no longer pre-packed with Visual Studio. However, in Visual Studio 2013 you can download them by using:
Tools > Extensions and Updates > Online (search) > Visual Studio Installer Projects

Thursday, 21 November 2019

Database Attaching Error in sql


Database Attaching Error in sql

CREATE
 DATABASE MyAdventureWorks  

    ON (FILENAME = 'D:\WINDB\PIANONEW.mdf'),   This is my .mdf  file path
    (FILENAME = 'D:\WINDB\PIANONEW.ldf')   This is my .ldf  file path
    FOR ATTACH; 


If  You are getting error on .ldf then remove .ldf from above code
this will help you

Maximum report processing jobs limit

Maximum report processing jobs limit


Use Below method this will help you

ReportDocument crystalReport = new ReportDocument();
 
protected void Page_Unload(object sender, EventArgs e)
    {
        crystalReport.Close();
        crystalReport.Dispose();
    }

On each load you have to dispose your crystal session

Wednesday, 13 November 2019

Need sample Birthday Calendar.(ASP.NET using C#)

Need sample Birthday Calendar.(ASP.NET using C#)


      We below given link it may help you

      http://www.beansoftware.com/ASP.NET-Tutorials/Calendar-Web-Application.aspx

Tuesday, 12 November 2019

Call JavaScript function (in aspx) on aspx.cs using a button

Call JavaScript function (in aspx) on aspx.cs using a button


I have you this but this is not working 
protected void button_Click(object sender , EventArgs e)
{
        string jsMethodName= = "NewPage()";
        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "uniqueKey", jsMethodName, true);

      //or
      //ScriptManager.RegisterStartupScript(this, GetType(), "NewPage()", false); 
}
Actually I want to open popup modal


Kindly Help 
Thanks In Advance

modify the data type of the column from INT to VARCHAR:

 Modify the data type of the column from INT to VARCHAR:



You have to use alter command see below:

ALTER TABLE Mytablename ALTER COLUMN tablecolumn VARCHAR (2);

Friday, 8 November 2019

The IListSource does not contain any data sources.

The IListSource does not contain any data sources.


If you are getting error on this that mean you don't have written this statement see below

sda.Fill(ds);

use this

  SqlCommand cmd = new SqlCommand("Select * from Student_Master", con);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            Repeater1.DataSource = ds;
            Repeater1.DataBind();

The IListSource does not contain any data sources.

The IListSource does not contain any data sources.


why I am getting error when bind repeater control of asp

need a help
thanks in advance

Dynamically Bind Repeater Control In ASP.NET From


Dynamically Bind Repeater Control In ASP.NET 

See below

 <asp:Repeater ID="Repeater1" runat="server">
                <ItemTemplate>
                    <table class="table table-bordered">
                        <tr>
                            <td style="width: 20%;">
                                <img alt="" width="150" class="img-thumbnail" src='<%#Eval("Profile_Picture")%>' />
                            </td>
                       
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:Repeater>

 private void BindRepeator()
    {
        con.Open();
        try
        {

            SqlCommand cmd = new SqlCommand("Select * from Student_Master", con);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            Repeater1.DataSource = ds;
            Repeater1.DataBind();
        }
        catch (SqlException)
        {

        }
        finally
        {
            con.Close();
        }
     
    }
This will help you

RowDataBound Event In GridView In ASP.NET



RowDataBound Event In GridView In ASP.NET


  1. <form id="form1" runat="server">  
  2.     <div>  
  3.         <asp:GridView ID="GridView1" runat="server" CellPadding="6" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound">  
  4.             <Columns>  
  5.                 <asp:BoundField DataField="Id" HeaderText="Id"/>  
  6.                 <asp:BoundField DataField="Name" HeaderText="Name"/>  
  7.                 <asp:BoundField DataField="City" HeaderText="City"/>  
  8.                 <asp:BoundField DataField="Salary" HeaderText="Salary"/>  
  9.             </Columns>  
  10.         </asp:GridView>  
  11.     </div>  
  12. </form>  


  1.  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)  
  2.     {  
  3.         //Checking the RowType of the Row  
  4.         if(e.Row.RowType==DataControlRowType.DataRow)  
  5.         {  
  6.             //If Salary is less than 10000 than set the row Background Color to Cyan  
  7.             if(Convert.ToInt32(e.Row.Cells[3].Text)<10000)  
  8.             {  
  9.                 e.Row.BackColor = Color.Cyan;  
  10.             }  
  11.         }  
  12.     } 

Thursday, 7 November 2019

Datetime add 1 month to current day

Datetime add 1 month to current day


If you want next month date write DateTime.Now.AddMonths(1) simlary it's depend on you how much month or year you want to add.

If you want to add Mont From a Fix Date then First Convert it to dateteTime like See below

 Convert.ToDateTime(txtInstDate.Text).AddMonths(addmd)


addmd is my month number like 1,2,3,4 and So on try this



Tuesday, 5 November 2019

PDF Export only exporting one page??

PDF Export only exporting one page??


use this 
     crystalReport.ExportToHttpResponse
                             (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "Barcode");
           

Monday, 4 November 2019

Calendar control not working...

Calendar control not working...


I am using crystal report viewer and the ajax calendar for a range it is working on local. But when it on the web server calendar is not working .Need of help

Thanks in advanced

ReportViewer Calendar button Click does not show calendar

ReportViewer Calendar button Click does not show calendar






I have a reportviewer on a page which is grabbing a report from a report server. the page is basically just a dropdownlist and a reportviewer control. The problem I have is that in the report the user have to provide the dates for teh report. The reportviewer automatically adds the textbox for the date entry and a calendar icon in front of it so the user can select the date. if I look at this page  in FireFox, when you click on the calendar button created by the reportviewer, the calendar control show up momentrily and dispappears. If you look at the same page in IE 7.0 nothing happens other than the page appears to be submitted. Does any body have any ideas on how to go about troubleshooting this bug?

Thanks

synchronize data only between local database and remote database

synchronize data only between local database and remote database



Hi all,
I have a web application published to remote server. user use it in case of internet existance.
there is another published version on local pc "sql server express 2008" . in case of there is no Internet connection ,user will use it from local pc.
how can i update remote database with new data of local database when there is no internet connection?
thanks

How to synchronize two SQL Server Databases automatically using C# .Net