Saturday 18 July 2020

Angular - Example 4 - Page Navigation Using Router(Call Component)


1. Create New Project Using Following Cmd - ng new PageNavigation - PageNavigation as Project Name

2. Open Visual Studio Code Application and open project.

3. Generate new component using cmd - 'ng g c PageList\Page1'
                                                              'ng g c PageList\Page2'
                                                              'ng g c PageList\Page3'
   g - generate 
   c - Component 
   PageList - New Folder Name
   Page1 - new Component Name


4. 4 new files are created for each new component - .html, .spec.ts, .ts, .css


5. After Creating New Component automatically changed in 'app.module.ts' file.


6. Open the file 'app-routing.module.ts' and changed code in the file - like below image


7. Open the file 'app.component.html' and changed code in the file - like below image


8. Open the file 'app.component.ts' and changed code in the file - like below image


9. And to complie and run this project -- ng serve --o

Output

A. If Page is empty



B. After click link button Redirect Page2 



C. After click button Redirect Page3



Sunday 12 July 2020

Angular - Example 3 - Create New Component and Call Component Content in App Component

1. Create New Project Using Following Cmd - ng new NewComponent - NewComponent as Project Name

2. Open Visual Studio Code Application and open project.

3. Generate new component using cmd - 'ng g c Master\CustomerMaster'
   g - generate 
   c - Component 
   Master - New Folder Name
   CustomerMaster - new Component Name


4. 4 new files are created for new component - .html, .spec.ts, .ts, .css



5. After Creating New Component automatically changed in 'app.module.ts' file.


6. Open the file 'customer-master.component.html' and changed code to <p>customer-master works!</p>



7. Selector name get from 'customer-master.component.ts' file and include into with tag in 'app.component.html' file.




8. And to complie and run this project -- ng serve --o


OUTPUT


Saturday 11 July 2020

Angular - Example 2 - Include Html TextBox Control and Onclick and OnChange Event

1. Create New Project Using Following Cmd - ng new TextBoxCtrl - TextBoxCtrl as Project Name

2. Open Visual Studio Code Application and open project.

3. In index.html file having app-root tag. This app-root tag controls loaded from
'..\src\app\app.component.html' file.




4. selector name is mentioned in '..\src\app\app.component.ts' file. This name to use to call the component.
(Components are the most basic UI building block of an Angular app. An Angular app contains a tree of Angular components.)



5. Include html code inside in app.component.html file.
ex : <input type="text" (click)="callfunc()" />
     <input type="text" [(ngModel)]="Name" (change)="change(Name)" />



6. Include below code inside in app.component.ts file.

exsiting page

after code change(marked blue)


7. Include below code inside in app.module.ts file.

exsiting page

after code change(marked blue)

8. And to complie and run this project -- ng serve --o


Output

When i click first text box and shows alert


After typed in text box and leaves from textbox - shows alert with typed text.


Friday 10 July 2020

First Program in Angular

Angular - Example 1


1. Create a Folder in Any Location (ex : E:\Angular_Examples\Example1)

2. Open Cmd - E:\Angular_Examples\Example1> to select specific location


3. Create New Project Using Following Cmd - ng new Welcome1 - Welcome1 as Project Name





4. Open Visual Studio Code Application and open project using below screen shot.




5. Complie program Command - ng serve




6. After complie project in cmd showing localhost url to copy and paste to browser and access the web application.




7. Terminate running project using cmd - ctrl + c




8. Complie and Run Command - ng serve --o



9. Automatically complied and application opened in the browser

How to Install Angular?

1. Install Visual Studio Code - https://code.visualstudio.com/
2. Install Angular - https://nodejs.org/en/download/ and https://cli.angular.io/

Saturday 3 October 2015

In GridView MouseOver Event Get Another Information based on gridview(StateName with City Name)

Design Page

css

<style type="text/css">
        body 
        {
            font-family:Arial, Tahoma;
            font-size:15px;
        }
        .grid 
        {
            width:100%;
            font:inherit;
            background-color:#FFF;
            border:solid 1px #525252;
        }
        .grid td
        {
            font:inherit;
            padding:3px 5px;
            border:solid 1px #C1C1C1;
            color:#333;
            text-align:left;
        }
        .grid th 
        {
            padding:3px;
            color:#FFF;
            background:#424242;
            border-left:solid 1px #525252;
            font:inherit;
            text-align:center;
            text-transform:uppercase;
        }       
        h3
        {
            color:#000;
            text-decoration:underline;
        }
        #divDetail 
        {
            float:left;
            font:inherit;
            font-size:13px;
            padding:2px 5px;
            width:auto;
            border:solid 2px #CCC;
            -moz-border-radius:0 7px 7px 0; -webkit-border-radius:0 7px 7px 0;
            border-radius:0 7px 7px 0;
            display:none;
            color:#333;
        }
        #divDetail p {
            font:inherit;
        }
        #divDetail a 
        {
            font:inherit;
            float:right;
            background-color:#357AE8;
            color:#FFF;
            text-decoration:none;
            border:solid 1px #2F5BB7;
            border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;
            padding:3px;
        }
    </style>


Script

<script type="text/javascript">       
        var iRowIndex;    // THE ROW INDEX OF THE GRIDVIEW, TO KEEP THE ROW HIGHLIGHTING
                    // WHEN THE MOUSE IS ON ANOTHER CONTROL.

        function MouseEvents(objRef, evt, desc) {

            if (evt.type == "mouseover") {

                objRef.style.cursor = 'pointer'
                objRef.style.backgroundColor = "#EEE";
                ShowDiv(desc, evt.pageY);

            }
            else {

                objRef.style.backgroundColor = "#FFF";
                iRowIndex = objRef.rowIndex;
                HideDiv();

            }
        }
        function ShowDiv(desc, pos) {

            // SHOW THE DIV WITH DESCRIPTIONS NEXT TO THE SELECTED GRIDVIEW ROW.

            document.getElementById('divDetail').style.display = 'block';
            document.getElementById('divDetail').innerHTML = desc;
            document.getElementById('divDetail').style.marginTop = pos - 25 + 'px';
        }

        function HideDiv() { document.getElementById('divDetail').style.display = 'none'; }

        function highlight(objRef, evt) {
            if (evt.type == "mouseover") {
                objRef.style.display = 'block';
                document.getElementById('gvEmployee').rows[iRowIndex].style.backgroundColor = "#EEE";
            }
            else {
                if (evt.type == "mouseout") {
                    document.getElementById('gvEmployee').rows[iRowIndex].style.backgroundColor = "#FFF";
                    objRef.style.display = 'none';
                }
            }
        }
    </script>


Design 
<div id="divGrid" style="width:auto; float:left">

            <h3>LIST OF EMPLOYEES</h3>
           
            <%--THE DATABOUND GRIDVIEW CONTROL.--%>
            <asp:GridView ID="gvEmployee" AutoGenerateColumns="False" OnRowDataBound ="gvEmployee_RowDataBound"
                CssClass="grid" GridLines="None"
                cellpadding="3" runat="server">

                <Columns>
                    <asp:BoundField DataField="StateId" HeaderText="Code" />
                    <asp:BoundField DataField="StateName" HeaderText="Name" />
                </Columns>

                <HeaderStyle BackColor="Black" ForeColor="white" />

            </asp:GridView>
        </div>
       
        <%--THE FLOATING DIV TO SHOW EMPLOYEE DETAILS.--%>
        <div runat="server" id="divDetail" onmouseover="highlight(this, event)"
            onmouseout="highlight(this, event)"></div>


Code Page

protected void Page_Load(object sender, EventArgs e)
        {
            string constr = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;           
            SqlConnection con = new SqlConnection(constr);
            SqlDataAdapter da = new SqlDataAdapter("select StateId, StateName from StateMaster", con);
            DataTable dt = new DataTable();
            da.Fill(dt);

            gvEmployee.DataSource = dt;
            gvEmployee.DataBind();
        }


        protected void gvEmployee_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
        {
            // BIND DATA WITH EACH ROW.
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                String sDetails = System.String.Empty;
                sDetails = "<span><h3>OTHER DETAILS</h3></span>";

                string constr = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
                using (SqlConnection con = new SqlConnection(constr))
                {
                    using (SqlCommand cmd = new SqlCommand("select * from CityMaster WHERE StateId = " +
                            DataBinder.Eval(e.Row.DataItem, "StateId").ToString()))
                    {
                        SqlDataAdapter sda = new SqlDataAdapter();
                        try
                        {
                            cmd.Connection = con;
                            con.Open();
                            sda.SelectCommand = cmd;

                            DataTable dt = new DataTable();
                            sda.Fill(dt);

                            if (dt.Rows.Count > 0)
                            {
                                sDetails = sDetails + "<p><strong>City Code: </strong>" +
                                    dt.Rows[0]["CityCode"] + "</p>";
                                sDetails = sDetails + "<p><strong>City Name: </strong>" +
                                    dt.Rows[0]["CityName"] + "</p>";

                                // BIND MOUSE EVENT (TO CALL JAVASCRIPT FUNCTION), WITH EACH ROW OF THE GRID.
                                e.Row.Attributes.Add("onmouseover", "MouseEvents(this, event, '" + sDetails + "')");
                                e.Row.Attributes.Add("onmouseout", "MouseEvents(this, event, '" +
                                    DataBinder.Eval(e.Row.DataItem, "StateId").ToString() + "')");
                            }

                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
        }


OUTPUT
 


Monday 19 May 2014

How to Clear All Stored Procedure in Particular DataBase

USE myDatabase //Database Name

GOdeclare @procName sysname declare someCursor cursor for select name from sysobjects where type = 'P' and objectproperty(id, 'IsMSShipped') = 0open someCursor fetch next from someCursor into @procName while @@FETCH_STATUS = while @@FETCH_STATUS = while @@FETCH_STATUS = 0begin exec('drop proc ' + @procName) fetch next from someCursor into @procName endclose someCursor deallocate someCursor go