Search Your Dot Net Topic

Sunday 4 July 2021

Sunday 23 May 2021

a potentially dangerous request.path value was detected from the client (&)





a potentially dangerous request.path value was detected from the client (&). asp.net

<system.web>
    <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
    <pages validateRequest="false" />
</system.web>

sqlconnection sqldatatadapter c# asp.net | ado.net sqlconnection and sqldataadapter select command




Detail view of SQLCONNECTION, SQLDATAADAPTER and datatable all in one.









<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdoNet-SqlConnect-SqlAdapter.aspx.cs" Inherits="AdoNet_SqlConnect_SqlAdapter" %>


<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:GridView ID="GridView1" runat="server"></asp:GridView>

    </div>

    </form>

</body>

</html>





codebehind c# code

using System;

using System.Collections.Generic;

using System.Configuration;

using System.Data;

using System.Data.SqlClient;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


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

{

    protected void Page_Load(object sender, EventArgs e)

    {

        if(!IsPostBack)

        {

            string ConString = ConfigurationManager.ConnectionStrings["dbLearningConnectionString"].ToString() ;

            SqlConnection con = new SqlConnection(ConString);

            con.Open();

            SqlDataAdapter da = new SqlDataAdapter("Select * From dbFriends", con);

            DataTable dt = new DataTable();

            da.Fill(dt);

            con.Close();

            GridView1.DataSource = dt;

            GridView1.DataBind();

        }

    }

foxpro report writer | vfp report | foxpro report in hindi | vfp report ...


REPORT COMMAND


create report <filename>  
* to create a report file.

modi report <filename>
* to create or modify a report file.


report form repfriend preview
*to preview a report

report form repfriend to print prompt
*to print report with printer selection dialog box.

Sunday 16 May 2021

Asp.Net C# the-remote-certificate-is-invalid-according-to-the-validation-procedure | SMTP Certificate Error



I had given solution in C# and VB.NET for Asp.Net C# the-remote-certificate-is-invalid-according-to-the-validation-procedure 


copy text which in bold letter is solution command.

C#  Solution:
  public static bool SendEmail(string toEmail, string subject, string msgBody, string FileName = "")
  {
    bool flag = true;

    string FromAddress = ConfigurationManager.AppSettings("FromAddress");
    System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
    System.Net.Configuration.MailSettingsSectionGroup settings = (System.Net.Configuration.MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");
    SmtpClient client = new SmtpClient();
    // If Not (client.Host = "localhost" Or client.Host = "127.0.0.1") Then
    System.Net.NetworkCredential credential = new System.Net.NetworkCredential(settings.Smtp.Network.UserName, settings.Smtp.Network.Password);
    client.Host = settings.Smtp.Network.Host;
    client.Port = settings.Smtp.Network.Port;
    client.UseDefaultCredentials = false;
    client.Credentials = credential;
    client.EnableSsl = ConfigurationManager.AppSettings("IsSSL");
    // Else
    // client = New SmtpClient("localhost")
    // End If
    MailMessage mailMsg = new MailMessage();

    mailMsg.From = new MailAddress(FromAddress);
    var listoftos = Regex.Split(toEmail, ",|;");
    foreach (var toeid in listoftos)
        mailMsg.To.Add(new MailAddress(toeid));
    string bcc = ConfigurationManager.AppSettings("ToBCC");
    var listofbcc = Regex.Split(bcc, ",|;");
    foreach (var Item in listofbcc)
        mailMsg.Bcc.Add(new MailAddress(Item));


    mailMsg.IsBodyHtml = true;
    mailMsg.Subject = subject;
    if (Strings.Trim(FileName) != "" && System.IO.File.Exists(FileName) == true)
        mailMsg.Attachments.Add(new Attachment(FileName));
    msgBody = msgBody.Replace("[siteurl]", ConfigurationManager.AppSettings("MainSite"));
    mailMsg.Body = msgBody;
    mailMsg.Priority = MailPriority.Normal;

//Add this line to bypass the certificate validation
        System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s,
                System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                System.Security.Cryptography.X509Certificates.X509Chain chain,
                System.Net.Security.SslPolicyErrors sslPolicyErrors)
                {
                    return true;
                };
    client.Send(mailMsg);

    return flag;
}


VB.NET Solution:

 Public Shared Function SendEmail(ByVal toEmail As String, ByVal subject As String, ByVal msgBody As String, Optional ByVal FileName As String = "") As Boolean
        Dim flag As Boolean = True

        Dim FromAddress As String = ConfigurationManager.AppSettings("FromAddress")
        Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath)
        Dim settings As System.Net.Configuration.MailSettingsSectionGroup = CType(config.GetSectionGroup("system.net/mailSettings"), System.Net.Configuration.MailSettingsSectionGroup)
        Dim client As New SmtpClient()
        'If Not (client.Host = "localhost" Or client.Host = "127.0.0.1") Then
        Dim credential As New System.Net.NetworkCredential(settings.Smtp.Network.UserName, settings.Smtp.Network.Password)
        client.Host = settings.Smtp.Network.Host
        client.Port = settings.Smtp.Network.Port
        client.UseDefaultCredentials = False
        client.Credentials = credential
        client.EnableSsl = ConfigurationManager.AppSettings("IsSSL")
        'Else
        'client = New SmtpClient("localhost")
        'End If
        Dim mailMsg As New MailMessage

        mailMsg.From = New MailAddress(FromAddress)
        Dim listoftos = Regex.Split(toEmail, ",|;")
        For Each toeid In listoftos
            mailMsg.To.Add(New MailAddress(toeid))
        Next
        Dim bcc As String = ConfigurationManager.AppSettings("ToBCC")
        Dim listofbcc = Regex.Split(bcc, ",|;")
        For Each Item In listofbcc
            mailMsg.Bcc.Add(New MailAddress(Item))
        Next


        mailMsg.IsBodyHtml = True
        mailMsg.Subject = subject
        If Trim(FileName) <> "" AndAlso System.IO.File.Exists(FileName) = True Then mailMsg.Attachments.Add(New Attachment(FileName))
        msgBody = msgBody.Replace("[siteurl]", ConfigurationManager.AppSettings("MainSite"))
        mailMsg.Body = msgBody
        mailMsg.Priority = MailPriority.Normal

        System.Net.ServicePointManager.ServerCertificateValidationCallback = Function(ByVal s As Object, ByVal certificate As System.Security.Cryptography.X509Certificates.X509Certificate, ByVal chain As System.Security.Cryptography.X509Certificates.X509Chain, ByVal sslPolicyErrors As System.Net.Security.SslPolicyErrors) True

        client.Send(mailMsg)

        Return flag
    End Function

connection string sql server vfp | connect vfp to sql server | visual fo...




1. First create ODBC  DSN.

2.  Start visual foxpro  establish connection 

*To establish connection with DSN name LearnDB
ConStat = SQLSTRINGCONNECT('dsn=LearnDB',.T.)


*To Check the connection.
?ConStat



*To check ConStat  value 
* if value > 0  it means connection established.

DISPLAY MEMORY


**To view the list of tblCities
GetCities = SQLEXEC(1,'Select * from tblCities',"Cities")

Friday 14 May 2021

accordion using repeater in asp.net | repeater control | how to create accordion in asp.net c#






SOURCE CODE:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="rpeater-accordian.aspx.cs" Inherits="rpeater_accordian" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#accordion" ).accordion();
  } );
  </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Repeater ID="rptAccord" runat="server">
            <HeaderTemplate>
                <div id="accordion">
            </HeaderTemplate>
            <ItemTemplate>
                <h3><%# Eval("FullName") %></h3>
                <div>
                    <ul>
                        <li><%# Eval("City") %></li>
                        <li><%# Eval("PhoneNumber") %></li>
                        <li><a href="mailto:<%# Eval("EmailID") %>"><%# Eval("EmailID") %></a></li>
                        <li><%# Eval("WebSite") %></li>
                    </ul>
                </div>
            </ItemTemplate>
            <FooterTemplate>
                </div>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    </form>
</body>
</html>









using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class rpeater_accordian : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        FriendDataClassesDataContext db = new FriendDataClassesDataContext();
        var MemList = (from a in db.dbMembers select a).ToList();
        rptAccord.DataSource = MemList;
        rptAccord.DataBind();
    }
}


Repeater control in asp.net c#, Repeater control example in asp.net c#






<%@ Page Language="C#" AutoEventWireup="true" CodeFile="repeater-normal.aspx.cs" Inherits="repeater_normal" %>


<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

    <style>

        table,tr,td{

            border:1px solid black;

        }

        th{

            font-size:14px;

        }

    </style>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:Repeater ID="rptMembers" runat="server">

            <HeaderTemplate>

                <table>

                <tr>

                    <th>FULLNAME</th>

                    <th>CITY</th>

                    <th>PHONE NUMBER</th>

                    <th>EMAIL ID</th>

                    <th>WEB SITE</th>

                </tr>

            </HeaderTemplate>

            

            <ItemTemplate>

                <tr style="background-color:lightblue;">

                    <td><%# Eval("FullName") %></td>

                    <td><%# Eval("City") %></td>

                    <td><%# Eval("PhoneNumber") %></td>

                    <td><%# Eval("EmailID") %></td>

                    <td><%# Eval("WebSite") %></td>

                </tr>

            </ItemTemplate>



            <AlternatingItemTemplate>

                <tr style="background-color:lightgray;">

                    <td><%# Eval("FullName") %></td>

                    <td><%# Eval("City") %></td>

                    <td><%# Eval("PhoneNumber") %></td>

                    <td><%# Eval("EmailID") %></td>

                    <td><%# Eval("WebSite") %></td>

                </tr>

            </AlternatingItemTemplate>


            <FooterTemplate>

                </table>

            </FooterTemplate>

        </asp:Repeater>

    </div>

    </form>

</body>

</html>









using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


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

{

    protected void Page_Load(object sender, EventArgs e)

    {

        FriendDataClassesDataContext db = new FriendDataClassesDataContext();

        var MemberList = (from a in db.dbMembers select a).ToList();

        rptMembers.DataSource = MemberList;

        rptMembers.DataBind();


    }

alternating item template in repeater asp.net c#| repeater control in asp.net c#



ASPX PAGE CODE:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="repeater-alternateitem.aspx.cs" Inherits="repeater_alternateitem" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style>
        table, tr,th,td{
            border:1px solid black;
        }
        th{
            font-size:20px;
        }

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Repeater ID="rptMembers" runat="server">
            <HeaderTemplate>
                <table>
                    <tr>
                        <th>
                            FULLNAME
                        </th>
                        <th>
                            CITY
                        </th>
                        <th>
                            PHONE NO.
                        </th>
                        <th>
                            EMAIL ID
                        </th>
                        <th>
                            WEB SITE
                        </th>
                    </tr>
                
            </HeaderTemplate>

            <ItemTemplate>
                <tr style="background-color:lightpink">
                    <td>
                        <%# Eval("FullName") %>
                    </td>
                    <td>
                        <%# Eval("City") %>
                    </td>
                    <td>
                        <%# Eval("PhoneNumber") %>
                    </td>
                    <td>
                        <%# Eval("EmailID") %>
                    </td>
                    <td>
                        <%# Eval("WebSite") %>
                    </td>
                </tr>
                
            </ItemTemplate>

            <AlternatingItemTemplate>
                <tr style="background-color:lightblue">
                    <td>
                        <%# Eval("FullName") %>
                    </td>
                    <td>
                        <%# Eval("City") %>
                    </td>
                    <td>
                        <%# Eval("PhoneNumber") %>
                    </td>
                    <td>
                        <%# Eval("EmailID") %>
                    </td>
                    <td>
                        <%# Eval("WebSite") %>
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    </form>
</body>
</html>





ASPX.CS  file CODE BEHIND CODE:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class rpeater_accordian : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        FriendDataClassesDataContext db = new FriendDataClassesDataContext();
        var MemList = (from a in db.dbMembers select a).ToList();
        rptAccord.DataSource = MemList;
        rptAccord.DataBind();
    }
}

Wednesday 12 May 2021

vfp create exe file | how to create exe file in visual foxpro | how to make exe file.




Command : 



CREATE PROJECT <filename>


example:    CREATE PROJECT Friend



select your startup and main file (menu file / login file).


print records using vfp report | vfp report writer | how to create report in visual foxpro






**OM SAI RAM
SET CLOCK on
SET CLOCK TO 07,80
CLOSE ALL 
CLEAR 

@ 05,01 To 22,100 doub 

@ 07,05 say "DATE : "+DMY(DATE())
@ 07,35 say "FRIEND SYSTEM" FONT "arial",14
@ 07,70 say "TIME : "
@ 09,02 TO 09,99


MButtonChoice = 0

USE friends

@ 18,15 Get MButtonChoice Function "*HT \<Print;\<Screen;\<Cancel" size 2,15,2

READ  cycle 

IF LASTKEY() = 27
RETURN .T.
ENDIF 


IF LASTKEY() <> 27


*For Printing
IF MButtonChoice = 1
REPORT FORM FriendList TO PRINTER PROMPT 
RETURN .t.  
ENDIF 


*For Preview
IF MButtonChoice = 2
REPORT FORM FriendList PREVIEW 
RETURN .t.  
ENDIF 


*For Cancel /exit
IF MButtonChoice = 3
WAIT WINDOW "You selected Cancel button."
Endif 


ENDIF 


delete record using prg file | remove record into dbf file using prg | P...








**OM SAI RAM
SET CLOCK on
SET CLOCK TO 07,80
CLOSE ALL 
CLEAR 

@ 05,01 To 22,100 doub 

@ 07,05 say "DATE : "+DMY(DATE())
@ 07,35 say "FRIEND SYSTEM" FONT "arial",14
@ 07,70 say "TIME : "
@ 09,02 TO 09,99

MFriendName = SPACE(100)
MPhoneNo = SPACE(20)
MCity = SPACE(20)
MButtonChoice = 0

USE friends
DO ListFriends


@ 12,02 say "Friend Name"
@ 12,35 say MFriendName Picture "@K!" size 1,30,1 color w++/n

@ 14,02 say "Phone Number"
@ 14,35 Say MPhoneNo Pict "@K9999999999"  color w++/n

@ 16,02 Say "City"
@ 16,35 say MCity Pict "@K!" color w++/n

@ 18,15 Get MButtonChoice Function "*HT \<Delete;\<Cancel" size 2,15,2

READ  cycle 

IF LASTKEY() = 27
RETURN .T.
ENDIF 


IF LASTKEY() <> 27

IF MButtonChoice = 1
SELECT Friends
DELETE 
WAIT WINDOW "Friend Successfully Deleted"
RETURN .t.  
ENDIF 

IF MButtonChoice = 2
WAIT WINDOW "You selected Cancel button."
Endif 


ENDIF 



PROCEDURE ListFriends
SELECT Friends
MSelectVal = SPACE(10)
DEFINE WINDOW FriendList AT 00,00 SIZE 20,120 TITLE "[Type and Shoot]  Select Friend"  ;
SYSTEM color W++/N FONT 'FixedSys',10
MOVE WINDOW FriendList CENTER
ACTIVATE WINDOW FriendList
DEFINE POPUP FriendLst PROMPT FIELD FriendName+SPACE(2)+PhoneNo SCROLL Margin
@ 00,00 Get MSelectVal Popup FriendLst size 20,120
READ
MFriendName = Friends.FriendName
MPhoneNo = Friends.PhoneNo
MCity = Friends.City
DEACTIVATE WINDOW FriendList
RELEASE WINDOWS FriendList
DEACTIVATE POPUP FriendLst
RELEASE POPUP FriendLst











Foxpro Training Center:

Visual Foxpro online training tutor in mumbai, malad, kandivali, borivali, bihar, gorakhpur, patna, surat, nandurbar, nashik, pune, bikaner, ahemdabad, jodhpur, jamnagar, rajkot, manglore, banglore, hisar, rohtak, delhi, noida, gaziabad, merrut, mathura, agra.




Angular Training Center:

Angular online training tutor in mumbai, malad, kandivali, borivali, bihar, gorakhpur, patna, surat, nandurbar, nashik, pune, bikaner, ahemdabad, jodhpur, jamnagar, rajkot, manglore, banglore, hisar, rohtak, delhi, noida, gaziabad, merrut, mathura, agra.




ReactJS Training Center:

ReactJS online training tutor in mumbai, malad, kandivali, borivali, bihar, gorakhpur, patna, surat, nandurbar, nashik, pune, bikaner, ahemdabad, jodhpur, jamnagar, rajkot, manglore, banglore, hisar, rohtak, delhi, noida, gaziabad, merrut, mathura, agra.

edit record using prg file | upate record into dbf file using prg | PRG file update modify record

 





Edit Module Source code Visual Foxpro training.


FILE NAME :   EditFriend.Prg

**OM SAI RAM
SET CLOCK on
SET CLOCK TO 07,80
CLOSE ALL 
CLEAR 

@ 05,01 To 22,100 doub 

@ 07,05 say "DATE : "+DMY(DATE())
@ 07,35 say "FRIEND SYSTEM" FONT "arial",14
@ 07,70 say "TIME : "
@ 09,02 TO 09,99

MFriendName = SPACE(100)
MPhoneNo = SPACE(20)
MCity = SPACE(20)
MButtonChoice = 0

USE friends
DO ListFriends


@ 12,02 say "Friend Name"
@ 12,35 Get MFriendName Picture "@K!" valid  !EMPTY(MFriendName) size 1,30,1

@ 14,02 say "Phone Number"
@ 14,35 Get MPhoneNo Pict "@K9999999999" 

@ 16,02 Say "City"
@ 16,35 Get MCity Pict "@K!"

@ 18,15 Get MButtonChoice Function "*HT \<Save;\<Cancel" size 2,15,2

READ  cycle 

IF LASTKEY() = 27
RETURN .T.
ENDIF 


IF LASTKEY() <> 27

IF MButtonChoice = 1
SELECT Friends
replace friendname WITH MFriendName
replace PhoneNo WITH MPhoneNo
replace city WITH Mcity
WAIT WINDOW "Friend Successfully Updated"
RETURN .t.  
ENDIF 

IF MButtonChoice = 2
WAIT WINDOW "You selected Cancel button."
Endif 


ENDIF 



PROCEDURE ListFriends
SELECT Friends
MSelectVal = SPACE(10)
DEFINE WINDOW FriendList AT 00,00 SIZE 20,120 TITLE "[Type and Shoot]  Select Friend"  ;
SYSTEM color W++/N FONT 'FixedSys',10
MOVE WINDOW FriendList CENTER
ACTIVATE WINDOW FriendList
DEFINE POPUP FriendLst PROMPT FIELD FriendName+SPACE(2)+PhoneNo SCROLL Margin
@ 00,00 Get MSelectVal Popup FriendLst size 20,120
READ
MFriendName = Friends.FriendName
MPhoneNo = Friends.PhoneNo
MCity = Friends.City
DEACTIVATE WINDOW FriendList
RELEASE WINDOWS FriendList
DEACTIVATE POPUP FriendLst
RELEASE POPUP FriendLst



Tuesday 11 May 2021

Call Codebehind method from GridView TemplateField ItemTemplate | Gridvi...





Source Code: 


Database Table :


USE [dbLearning]
GO

/****** Object:  Table [dbo].[dbFriends]    Script Date: 10-05-2021 23:52:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[dbFriends](
[FriendID] [int] IDENTITY(1,1) NOT NULL,
[FriendName] [varchar](100) NULL,
[Mobile] [varchar](50) NULL,
[CityID] [int] NULL,
 CONSTRAINT [PK_dbFriends] PRIMARY KEY CLUSTERED 
(
[FriendID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO



USE [dbLearning]
GO

/****** Object:  Table [dbo].[tblCities]    Script Date: 11-05-2021 00:04:07 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblCities](
[CityID] [int] IDENTITY(1,1) NOT NULL,
[CityName] [varchar](50) NULL,
 CONSTRAINT [PK_tblCities] PRIMARY KEY CLUSTERED 
(
[CityID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO






Code of List-of-Friends.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="list-of-friends.aspx.cs" Inherits="list_of_friends" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:GridView ID="gvFriend" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:BoundField DataField="FriendName" HeaderText="Friend Name" />
            <asp:BoundField DataField="Mobile" HeaderText ="Mobile Number" />
            <asp:TemplateField HeaderText ="Friend City">
                <ItemTemplate>
                    <%# GetCityNameByCityID(Convert.ToString(Eval("CityID"))) %>
                </ItemTemplate>
            </asp:TemplateField>

        </Columns>
    </asp:GridView>
    </div>
    </form>
</body>
</html>






Code of List-of-Friends.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class list_of_friends : System.Web.UI.Page
{
    FriendDataClassesDataContext db = new FriendDataClassesDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var friendlist = (from a in db.dbFriends select a).ToList();
            gvFriend.DataSource = friendlist;
            gvFriend.DataBind();
        }
    }

    public string GetCityNameByCityID(string _CityID)
    {
        string CityName = string.Empty;

        var cityDetail = (from a in db.tblCities
                            where a.CityID == Convert.ToInt32(_CityID)
                          select a).FirstOrDefault();

        if(cityDetail != null)
        {
            CityName = cityDetail.CityName;
        }
        return CityName;
    }

    

}

Monday 10 May 2021

Login form asp.net webform | login sample asp.net | login page in asp.net c# | login asp.net


 https://www.youtube.com/watch?v=A-ix-A4cT9o


Source Code:

Login.aspx  page  code:



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>


<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

    <style>

        body {

background: #DCDDDF url(https://cssdeck.com/uploads/media/items/7/7AF2Qzt.png);

color: #000;

font: 14px Arial;

margin: 0 auto;

padding: 0;

position: relative;

}

h1{ font-size:28px;}

h2{ font-size:26px;}

h3{ font-size:18px;}

h4{ font-size:16px;}

h5{ font-size:14px;}

h6{ font-size:12px;}

h1,h2,h3,h4,h5,h6{ color:#563D64;}

small{ font-size:10px;}

b, strong{ font-weight:bold;}

a{ text-decoration: none; }

a:hover{ text-decoration: underline; }

.left { float:left; }

.right { float:right; }

.alignleft { float: left; margin-right: 15px; }

.alignright { float: right; margin-left: 15px; }

.clearfix:after,

form:after {

content: ".";

display: block;

height: 0;

clear: both;

visibility: hidden;

}

.container { margin: 25px auto; position: relative; width: 900px; }

#content {

background: #f9f9f9;

background: -moz-linear-gradient(top,  rgba(248,248,248,1) 0%, rgba(249,249,249,1) 100%);

background: -webkit-linear-gradient(top,  rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);

background: -o-linear-gradient(top,  rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);

background: -ms-linear-gradient(top,  rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);

background: linear-gradient(top,  rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f8f8f8', endColorstr='#f9f9f9',GradientType=0 );

-webkit-box-shadow: 0 1px 0 #fff inset;

-moz-box-shadow: 0 1px 0 #fff inset;

-ms-box-shadow: 0 1px 0 #fff inset;

-o-box-shadow: 0 1px 0 #fff inset;

box-shadow: 0 1px 0 #fff inset;

border: 1px solid #c4c6ca;

margin: 0 auto;

padding: 25px 0 0;

position: relative;

text-align: center;

text-shadow: 0 1px 0 #fff;

width: 400px;

}

#content h1 {

color: #7E7E7E;

font: bold 25px Helvetica, Arial, sans-serif;

letter-spacing: -0.05em;

line-height: 20px;

margin: 10px 0 30px;

}

#content h1:before,

#content h1:after {

content: "";

height: 1px;

position: absolute;

top: 10px;

width: 27%;

}

#content h1:after {

background: rgb(126,126,126);

background: -moz-linear-gradient(left,  rgba(126,126,126,1) 0%, rgba(255,255,255,1) 100%);

background: -webkit-linear-gradient(left,  rgba(126,126,126,1) 0%,rgba(255,255,255,1) 100%);

background: -o-linear-gradient(left,  rgba(126,126,126,1) 0%,rgba(255,255,255,1) 100%);

background: -ms-linear-gradient(left,  rgba(126,126,126,1) 0%,rgba(255,255,255,1) 100%);

background: linear-gradient(left,  rgba(126,126,126,1) 0%,rgba(255,255,255,1) 100%);

    right: 0;

}

#content h1:before {

background: rgb(126,126,126);

background: -moz-linear-gradient(right,  rgba(126,126,126,1) 0%, rgba(255,255,255,1) 100%);

background: -webkit-linear-gradient(right,  rgba(126,126,126,1) 0%,rgba(255,255,255,1) 100%);

background: -o-linear-gradient(right,  rgba(126,126,126,1) 0%,rgba(255,255,255,1) 100%);

background: -ms-linear-gradient(right,  rgba(126,126,126,1) 0%,rgba(255,255,255,1) 100%);

background: linear-gradient(right,  rgba(126,126,126,1) 0%,rgba(255,255,255,1) 100%);

    left: 0;

}

#content:after,

#content:before {

background: #f9f9f9;

background: -moz-linear-gradient(top,  rgba(248,248,248,1) 0%, rgba(249,249,249,1) 100%);

background: -webkit-linear-gradient(top,  rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);

background: -o-linear-gradient(top,  rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);

background: -ms-linear-gradient(top,  rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);

background: linear-gradient(top,  rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f8f8f8', endColorstr='#f9f9f9',GradientType=0 );

border: 1px solid #c4c6ca;

content: "";

display: block;

height: 100%;

left: -1px;

position: absolute;

width: 100%;

}

#content:after {

-webkit-transform: rotate(2deg);

-moz-transform: rotate(2deg);

-ms-transform: rotate(2deg);

-o-transform: rotate(2deg);

transform: rotate(2deg);

top: 0;

z-index: -1;

}

#content:before {

-webkit-transform: rotate(-3deg);

-moz-transform: rotate(-3deg);

-ms-transform: rotate(-3deg);

-o-transform: rotate(-3deg);

transform: rotate(-3deg);

top: 0;

z-index: -2;

}

#content form { margin: 0 20px; position: relative }

#content form input[type="text"],

#content form input[type="password"] {

-webkit-border-radius: 3px;

-moz-border-radius: 3px;

-ms-border-radius: 3px;

-o-border-radius: 3px;

border-radius: 3px;

-webkit-box-shadow: 0 1px 0 #fff, 0 -2px 5px rgba(0,0,0,0.08) inset;

-moz-box-shadow: 0 1px 0 #fff, 0 -2px 5px rgba(0,0,0,0.08) inset;

-ms-box-shadow: 0 1px 0 #fff, 0 -2px 5px rgba(0,0,0,0.08) inset;

-o-box-shadow: 0 1px 0 #fff, 0 -2px 5px rgba(0,0,0,0.08) inset;

box-shadow: 0 1px 0 #fff, 0 -2px 5px rgba(0,0,0,0.08) inset;

-webkit-transition: all 0.5s ease;

-moz-transition: all 0.5s ease;

-ms-transition: all 0.5s ease;

-o-transition: all 0.5s ease;

transition: all 0.5s ease;

background: #eae7e7 url(https://cssdeck.com/uploads/media/items/8/8bcLQqF.png) no-repeat;

border: 1px solid #c8c8c8;

color: #777;

font: 13px Helvetica, Arial, sans-serif;

margin: 0 0 10px;

padding: 15px 10px 15px 40px;

width: 80%;

}

#content form input[type="text"]:focus,

#content form input[type="password"]:focus {

-webkit-box-shadow: 0 0 2px #ed1c24 inset;

-moz-box-shadow: 0 0 2px #ed1c24 inset;

-ms-box-shadow: 0 0 2px #ed1c24 inset;

-o-box-shadow: 0 0 2px #ed1c24 inset;

box-shadow: 0 0 2px #ed1c24 inset;

background-color: #fff;

border: 1px solid #ed1c24;

outline: none;

}

#username { background-position: 10px 10px !important }

#password { background-position: 10px -53px !important }

#content form input[type="submit"] {

background: rgb(254,231,154);

background: -moz-linear-gradient(top,  rgba(254,231,154,1) 0%, rgba(254,193,81,1) 100%);

background: -webkit-linear-gradient(top,  rgba(254,231,154,1) 0%,rgba(254,193,81,1) 100%);

background: -o-linear-gradient(top,  rgba(254,231,154,1) 0%,rgba(254,193,81,1) 100%);

background: -ms-linear-gradient(top,  rgba(254,231,154,1) 0%,rgba(254,193,81,1) 100%);

background: linear-gradient(top,  rgba(254,231,154,1) 0%,rgba(254,193,81,1) 100%);

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fee79a', endColorstr='#fec151',GradientType=0 );

-webkit-border-radius: 30px;

-moz-border-radius: 30px;

-ms-border-radius: 30px;

-o-border-radius: 30px;

border-radius: 30px;

-webkit-box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;

-moz-box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;

-ms-box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;

-o-box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;

box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;

border: 1px solid #D69E31;

color: #85592e;

cursor: pointer;

float: left;

font: bold 15px Helvetica, Arial, sans-serif;

height: 35px;

margin: 20px 0 35px 15px;

position: relative;

text-shadow: 0 1px 0 rgba(255,255,255,0.5);

width: 120px;

}

#content form input[type="submit"]:hover {

background: rgb(254,193,81);

background: -moz-linear-gradient(top,  rgba(254,193,81,1) 0%, rgba(254,231,154,1) 100%);

background: -webkit-linear-gradient(top,  rgba(254,193,81,1) 0%,rgba(254,231,154,1) 100%);

background: -o-linear-gradient(top,  rgba(254,193,81,1) 0%,rgba(254,231,154,1) 100%);

background: -ms-linear-gradient(top,  rgba(254,193,81,1) 0%,rgba(254,231,154,1) 100%);

background: linear-gradient(top,  rgba(254,193,81,1) 0%,rgba(254,231,154,1) 100%);

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fec151', endColorstr='#fee79a',GradientType=0 );

}

#content form div a {

color: #004a80;

    float: right;

    font-size: 12px;

    margin: 30px 15px 0 0;

    text-decoration: underline;

}

.button {

background: rgb(247,249,250);

background: -moz-linear-gradient(top,  rgba(247,249,250,1) 0%, rgba(240,240,240,1) 100%);

background: -webkit-linear-gradient(top,  rgba(247,249,250,1) 0%,rgba(240,240,240,1) 100%);

background: -o-linear-gradient(top,  rgba(247,249,250,1) 0%,rgba(240,240,240,1) 100%);

background: -ms-linear-gradient(top,  rgba(247,249,250,1) 0%,rgba(240,240,240,1) 100%);

background: linear-gradient(top,  rgba(247,249,250,1) 0%,rgba(240,240,240,1) 100%);

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f9fa', endColorstr='#f0f0f0',GradientType=0 );

-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.1) inset;

-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.1) inset;

-ms-box-shadow: 0 1px 2px rgba(0,0,0,0.1) inset;

-o-box-shadow: 0 1px 2px rgba(0,0,0,0.1) inset;

box-shadow: 0 1px 2px rgba(0,0,0,0.1) inset;

-webkit-border-radius: 0 0 5px 5px;

-moz-border-radius: 0 0 5px 5px;

-o-border-radius: 0 0 5px 5px;

-ms-border-radius: 0 0 5px 5px;

border-radius: 0 0 5px 5px;

border-top: 1px solid #CFD5D9;

padding: 15px 0;

}

.button a {

background: url(https://cssdeck.com/uploads/media/items/8/8bcLQqF.png) 0 -112px no-repeat;

color: #7E7E7E;

font-size: 17px;

padding: 2px 0 2px 40px;

text-decoration: none;

-webkit-transition: all 0.3s ease;

-moz-transition: all 0.3s ease;

-ms-transition: all 0.3s ease;

-o-transition: all 0.3s ease;

transition: all 0.3s ease;

}

.button a:hover {

background-position: 0 -135px;

color: #00aeef;

}

    </style>



</head>

<body>

    

    

        <div class="container">

<section id="content">

<form id="form1" runat="server">

<h1>Login Form</h1>

<div>

<asp:TextBox id="username" runat="server" ClientIDMode="Static"  placeholder="Username" required=""  />

</div>

<div>

<asp:TextBox id="password" runat="server" ClientIDMode="Static" TextMode="Password" placeholder="Password" required=""  />

</div>

<div>

<asp:Button ID="btnSubmit" Text="Log in" runat="server" OnClick="btnSubmit_Click" />

<a href="#">Lost your password?</a>

<a href="#">Register</a>

</div>

</form>

</section><!-- content -->

</div><!-- container -->

    

</body>

</html>








Login.aspx.cs  page  code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        FriendDataClassesDataContext db = new FriendDataClassesDataContext();

        var LoginCheck = (from a in db.tblLogins
                          where a.EmailID.ToLower() == username.Text.ToLower() &&
                                 a.Password.ToLower() == password.Text.ToLower()
                          select a).FirstOrDefault();

        if (LoginCheck != null)
        {
            Response.Redirect("default.aspx");
        }
        
        if (LoginCheck== null)
        {
            Response.Redirect("login.aspx?msg=invalid user and password");
        }
    }
}

Friday 7 May 2021

PRG file mainmenu | prg file of foxpro | prg base menu | create menu pr...




PRG file base menu code:



**OM SAI RAM
SET DATE BRITISH
SET TALK OFF
SET CONFIRM OFF
SET SAFETY OFF
SET CENTURY ON 
SET CLOCK on
SET CLOCK TO 07,80
CLEAR ALL
CLOSE ALL 
CLEAR 

DO WHILE .t.
@ 05,01 To 22,100 doub 

@ 07,05 say "DATE : "+DMY(DATE())
@ 07,35 say "FRIEND SYSTEM" FONT "arial",14
@ 07,70 say "TIME : "
@ 09,02 TO 09,99
@ 10,35 Prompt "  \<Add Friend    " Message "To enter an new friend detail."
@ 13,35 Prompt "  \<Edit Friend   " Message "To modifiy/edit a friend detail."
@ 16,35 Prompt "  \<Delete Friend " Message "To remove/erase a friend detail."
@ 19,35 Prompt "  E\<xit          " Message "To exit from friend system.."
menu to choice

IF choice = 1

cancel
ENDIF 


IF choice = 2
cancel

ENDIF 


IF choice = 3

cancel
ENDIF 

IF choice = 4

cancel
ENDIF 

ENDDO 


Sunday 2 May 2021

Overview Asp.Net Events | Event base programming in Asp.Net WebForm | Ev...





In this video lecture you will get ideas of what is event and importance of events in asp.net webform.

Logic of events base programming in asp.net webform.

Saturday 1 May 2021

ternary operator in vb net | ternary operator example vb.net | how to w...





<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ternary-operator-vbnet.aspx.vb" Inherits="ternary_operator_vbnet" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Label ID="lblResult" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>




Partial Class ternary_operator_vbnet
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim Marks = 45
        Dim ExamResult As String = If(Marks > 40, ”Pass”, “Fail”)
        lblResult.Text = ExamResult
    End Sub
End Class

Friday 30 April 2021

Asp.Net Session Practical | Session using Asp.Net WebForm | session in ...



Asp.Net Session  Practical


CODE: login.aspx

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <table>
                <tr>
                    <td>
                        User Name
                    </td>
                    <td>
                        <asp:TextBox ID="txtUsername" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                      Password
                    </td>
                    <td>
                        <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit"/>
                    </td>
                </tr>
            </table>
    </div>
    </form>
</body>
</html>



CODE: login.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(txtUsername.Text)  && txtPassword.Text.ToLower() == "abc12")
        {
            Session["LogUserName"] = txtUsername.Text;
            Response.Redirect("dashboard.aspx");
        }
    }
}






CODE: dashboard.aspx

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <h1>Welcome <asp:Label ID="lblUserName" runat="server"></asp:Label> </h1>
    </div>
    </form>
</body>
</html>



CODE: dashboard.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class dashboard : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string UserName = Convert.ToString(Session["LogUserName"]);
        if (!string.IsNullOrEmpty(UserName))
        {
            lblUserName.Text = UserName;
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
}