Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Call Web Service | SOAP | WSDL | asmx

Here ParameterService is a Service name on references and ParameterServiceSoapClient is a class name on autogenerated file  reference.cs .



 public void TestMethod()

        {

            try

            {

ParameterService.ParameterServiceSoapClient FObjFetchParameters = new                     ParameterService.ParameterServiceSoapClient();

                DataSet dtSurnoc = new DataSet();

               dtSurnoc = FObjFetchParameters.GetSNo(24,1,3,5,12);

              }

            catch (Exception ex)

            {

                throw;

            }

        }

c# read all table with column dataset / datatable

foreach (DataTable dtab in ds.Tables)
                    {
                       Console.WriteLine("Table - "+dtab.TableName);
                        foreach (DataColumn dc in dtab.Columns)
                        Console.WriteLine("Col- "+dc.ColumnName);
                    }

GridView - Selected row data using datakey name | Asp.Net c#


GridView - Dynamic Select Button  | Asp.Net c#


Home.aspx

asp:GridView runat="server" ID="GrdLandDetails" CssClass="table table-striped table-bordered table-hover gridasp" PageSize="10" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="id,age"  AutoGenerateSelectButton="true" OnSelectedIndexChanging="GrdLandDetails_SelectedIndexChanging"
                                             
  Columns
                                                    asp:BoundField HeaderText="Name" DataField="Sname"
                                                    asp:BoundField HeaderText="Amount" DataField="amt"
                                                    asp:


Home.aspx.cs  | Code Behind

  protected void gv_bindowners_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
  {
         string Fname = gv_bindowners.DataKeys[e.NewSelectedIndex].Values["Sname"].toString;
         string Age = gv_bindowners.DataKeys[e.NewSelectedIndex].Values["age"].toString;
         string Amount = gv_bindowners.DataKeys[e.NewSelectedIndex].Values["amt"].toString;
  }




                                             

Advanced Add Reference - capicom.dll

Add Assembly References in Asp.Net Visual Studio

Step1: Put capicom.dll in any drive.

Step2:  open cmd as administrator.

Step3:


Step4: Open Visual Studio on Solution Explorer, Add Reference



All in One | 1 Program that implement the concept of Method overriding, Methods Hidding / Abstraction and polymorphism.




  1. Base class references [a, b, c] can implement the method of child class prin() method that concept is Polymorphism
  2. Use override keyword implement Method Overriding
  3.  Use new keyword in child class that implement the concept of Method Hidding or Abstraction


String Manipulation| once time count each each word in string using C# console example with asp.net


Many companies asked during interview :
Write a function that returns count each with number of occurance in given string
Input      HAAHLHLLL
Output.     H occurance 3 times
                   A occurance 2 times
                  L occurance 4 times

String Manipulation | c# Interview Question with console code example

In this Example we can achieve
  1. Swapping String
  2. String to Character Array and wise versa
  3. Take Any Random Input
For ex. Input is ABCDEF
Then Output   BADCFE


imgbtn I ASP.NET C# | Image Button Properties | SMI Studio





using System;

using System.Web.UI;

using System.Drawing;

namespace WebApplication4

{

    public partial class WebForm1 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)

        {

            if (e.X >= 0 && e.X < (imbtn.Width.Value/2))

            {

                if (e.Y >= 0 && e.Y < (imbtn.Height.Value / 2))

                {

                    lbl.ForeColor = Color.Yellow;

                    lbl.Text = "you cicked on yellow button";

                }

                else

                {

                    lbl.ForeColor = Color.Red;

                    lbl.Text = "you cicked on RED button";

                }

            }

            else

            {

                if (e.Y >= 0 && e.Y < (imbtn.Height.Value / 2))

                {

                    lbl.ForeColor = Color.Blue;

                    lbl.Text = "you cicked on BLUE button";

                }

                else

                {

                    lbl.ForeColor = Color.Green;

                    lbl.Text = "you cicked on GREEN button";

                }



            }

         

        }

    }

}

Social Media