Wednesday 28 October 2015

Ajax Modal Pop Up Dot(.) Issue

Problem:Click On Target button and ajax modal pop up open with one dot(.)
           every time one dot will come.

Solution: Generally this issue we got when Ajax Modal pop Up open on click of grid view column.
                * put that grid in seperate <div></div>  tag.
                Issue will be resolved.



Wednesday 24 September 2014

Add New Image Icon with ID Column in Gridview in asp.net

 <asp:TemplateField HeaderText="CustomerId" SortExpression="CustomerId">
 <ItemTemplate>
<asp:Label ID="lcustomerid" runat="server" Text='<%# Bind("CustomerId") %>'></asp:Label>
<asp:HiddenField ID="hflcustomerid" runat="server" Value='<%# Eval("CustomerId") %>' />
<asp:Image ID="Image1" ImageAlign="Middle" ImageUrl='<%# "/Images/" + (Convert.ToBoolean(Eval("NewImage"))? "flashing_new.gif" : "Modify.png")  %>'  runat="server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ComplaintID") %>'></asp:TextBox>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
                                    </asp:TemplateField>

Friday 18 April 2014

Disposed Unwanted Objects in DotNet



                                 Dispose Unwanted Object Through WCF Service
1.       Open  Our Project  in Visual Studio.                                                                                                                   
2.       Go to Solution Explorer and open Web Project à WCF Service( Folder)  à Sales ( Folder)  à SalesClient.svc(Service)  and then open  SalesClient.svc.cs  file.                                                                           
3.       Add one file SilverlightFaultBehavior.cs  in our Web Project. This file is an auto-generated   file to enable WCF Fault s to reach Silverlight Clients. Main Use of SiverlightFaultBehavior.cs  file is to handling WCF Service Exceptions within Silverlight Application.



                                          
4.       Two new attributes we have added SilverlightFaultBehavior and ServiceBehavior.
5.       SalesClient is a service class.here we have implemented  an interface IDisposable.We have to use as implicitly.Namespace for IDisposable is System.
After Implement interface IDisposable one Dispose method will created at end.
then replace that Dispose method  code to above code mention here:
In Above Code Dispose ( ) method is use for implement IDisposable.here we called Garbage Collector for dispose unwanted object. SuppresFinalize method should only be called by a class that has a finalizer. It's informing the GC that this object was cleaned up fully. We can pass managed private object references inside if(disposing) block .
6.       ~SalesClient( ) is a finalizer. and it works as a destructor.
7.       Build that Web  and then update Service References those are related to  SalesClient.svc. That Service Reference exists which is our Silverlight Project.
For Update Service Reference Just Right Click on Service Reference and Click Update Service reference.
Note:
We can use same process for other server side layers if we want to disposed unwanted objects.

                                                                                                             


Sunday 9 June 2013

In Linq How To Use Sql Query:

 

 

1-Add a new item in your site. Add a LINQ to SQL Classes and name it

DataClasses.dbml.Place this file in the App_Code special folder.

2-From the Server Explorer / Data Explorer window drag the CustomerInfo table and drop it on the DataClasses.dbml.

3-Drag a Gridview web server control on the Default.aspx page. 

4-Write Code Behind button Button6_Click( ).

 

protected void Button6_Click(object sender, EventArgs e)
        {
            try
            {
                DataClassesDataContext dcc = new DataClassesDataContext();
                IEnumerable<CustomerInfo> results1 = dcc.ExecuteQuery<CustomerInfo>  (@"select CustomerId,CustomerName from CustomerInfo");
                GridView2.DataSource = results1;
                GridView2.DataBind();

            }
            catch (Exception ex)
            {
                Response.Redirect(ex.Message);
            }
        }


Tuesday 7 May 2013

Select,Insert,Update and Delete data with LINQ to SQL in an ASP.Net application

For Select-

1-Start Or Open Visual Studio 2010..

2-Add a new item in your site. Add a LINQ to SQL Classes and name it

DataClasses.dbml.Place this file in the App_Code special folder

3- From the Server Explorer / Data Explorer window drag the CustomerInfo table and drop it on the DataClasses.dbml.

4-Have a look at the generated code from the Linq engine in DataClasses.designer.cs

5-Drag a Gridview web server control on the Default.aspx page.

6- In the Page_Load event handling routine of the Default.aspx page type

   

   DataClassesDataContext dcc = new DataClassesDataContext();

      var emps = from myemp in dcc.CustomerInfos
      select myemp;
                       

        GridView1.DataSource = emps;
        GridView1.DataBind();

7- Run your application and see the results printed in the screen.

 

For Insert

1-Now let's try and insert a new record in our CustomerInfo table. Add a button in the Default.aspx page.Leave the default name.Change the Text property of the button control to "Insert".

2-Write Code Behind button Insert_Click( )-

 

  DataClassesDataContext dcc = new DataClassesDataContext();
  CustomerInfo myemp = new CustomerInfo();
   myemp.CustomerName = txtCustomerName.Text;
   myemp.CustomerAddress = txtCustomerAddress.Text;

          
    dcc.CustomerInfos.InsertOnSubmit(myemp);
     try
            {
                dcc.SubmitChanges();
                Response.Write("Inserted");
            }
     catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

3-Run your application and see the results printed in the screen.

 

For Delete-

1-Now let's try to delete the newly added record from our CustomerInfo table. Add a button in the Default.aspx page.Leave the default name.Change the Text property of the button control to "Delete".

2-write Code Behind Button Delete_Click( )-

3-TextBox3 is a field in which whatever CustomerId Or CustomerName Or, CustomerAddress you want to delete,you enter that value and press delete button. 

DataClassesDataContext dcc = new DataClassesDataContext();                                                      var myemp= dcc.CustomerInfos.Single(emp=> (emp.CustomerId.ToString() == TextBox3.Text)|| (emp.CustomerName == TextBox3.Text) || (emp.CustomerAddress == TextBox3.Text));
                dcc.CustomerInfos.DeleteOnSubmit(myemp);
                try
                {
                    dcc.SubmitChanges();
                    Response.Write("Deleted");
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }

4-Run your application and see the results printed in the screen.