Embed Youtube video in html

1. open your youtube link
2. Click on Share link, just below the subscribe button
11

3. You can see Embed link after clicking on share.

[There you find iframe code ]

4. copy iframe code and paste in your html file.

22

Iframe code

5. You can customize video width and height manually or can do it clicking on more option with some other options as well.

Iframe video in html displays as:

Insert Data using JSON ASP.NET Web services and jQuery

Hello everyone, today we will learn how to insert data in sql server database using json asp.net web services.
In sql server Database:
– Create your database
– Create a table with fields “Name, PhoneNumber, Email, Address”

2

In Visual Studio 2010
1. Open visual studio.
2. Go to file- new – website
3. Type your project name

1

Let us first create aspx page which will send our input values to the asmx page. Here we are using jquery -ajax for sending datas to .asmx page which will insert those data to sql database.

1. Now create a new aspx page

  • In solution explorer, right click then add new item
  • Select Web form
  • Enter page name eg:InsertData.aspx

3

2. Copy the below code in your aspx page.

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script type="text/javascript">
        function CallJsonService() {

            // Creating variables to hold data from textboxes
            var name = $('#_txtname').val();
            var phone = $('#_phone').val();
            var email = $('#_email').val();
          
            var addr = $('#_addr').val();
            alert(name);
            $.ajax({
                type: "POST",
                url: "insertdatajson.asmx/ReceiveWebservice",
                data: "{ 'name': '" + name + "','phone': '" + phone + "', 'email': '" + email + "','address':'" + addr + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function (data) {
                    $('#message').text(data.d);
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div><B> DATA INSERTION  USING JSON ASP.NET WEB SERVICES AND JQUERY</B></div><br /><br />
    <div style="margin:0 auto;width:1000px;">
        Name:
        <asp:TextBox ID="_txtname" runat="server"></asp:TextBox><br /><br />
         Phone:
        <asp:TextBox ID="_phone" runat="server"></asp:TextBox><br /><br />
        Email:
        <asp:TextBox ID="_email" runat="server"></asp:TextBox><br /><br />
       
        Adrss:
        <asp:TextBox ID="_addr" runat="server"></asp:TextBox><br /><br />
        <input id="_btnSubmit" type="button" value="Submit" onclick="CallJsonService();" />
        <span id="message"></span>
    </div>
    </form>
</body>
</html>

In the above code we are making post ajax call, where type is POST method, and the page to be called is insertdatajson.asmx and the data refers to the data to be passed to asmx page.On successful insertion we get success message.

3. In your web config file , add the connectionstring as :

 <connectionStrings>
    <add name="con" connectionString="server=ANIL-PC;uid=sa;pwd=emizr123;database=ServerCommunication"/>
  </connectionStrings>

4. Now again in solution explorer, add new item, select web service .
Name it as insertdatajson.asmx

4

5. In insertdatajson.asmx add the following code.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;


/// <summary>
/// Summary description for insertdatajson
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class insertdatajson : System.Web.Services.WebService {

    public insertdatajson () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    // getting connection string
    string conStr = WebConfigurationManager.ConnectionStrings["con"].ConnectionString;
    int rowsInserted = 0;
    [WebMethod]
    public string ReceiveWebservice(string name,string phone ,string email,  string address)
    {
        // Creating Sql Connection
        using (SqlConnection conn = new SqlConnection(conStr))
        {
            // Creating insert statement
            string sql = string.Format(@"INSERT INTO tbl_your_profile ([Name],[PhoneNumber],[Email],[Address])VALUES('{0}','{1}','{2}','{3}')", name,phone, email,  address);
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            conn.Open();
            rowsInserted = cmd.ExecuteNonQuery();
            conn.Close();
            cmd = null;

        }

        return string.Format("Congrats, {0} row has been updated", rowsInserted);
    }

}

Note: To allow this Web Service to be called from script, using ASP.NET AJAX,you should uncomment the following line.

[System.Web.Script.Services.ScriptService]

6. Now make your insertdata.aspx as start page. run it , then u get :

5

7. Fill up the fields and click submit:

6

8. Now your table will contain the data that you entered.

7

9. You can even make insertdatajson.asmx as start page, then you can directly fill the data from it.
1

on clicking ReceiveWebservice, you get screen like:

2

After you click invoke option, data gets inserted into the database.

3

Now your table appears as:

4

You can call above asp web service from any other platforms like iphone, android.

Download above sample application Here

How to use Scroll View in Xcode

i am going to show you all how to use scroll view in xcode and make it work.

1. Create single view application
Screen Shot 2014-11-01 at 8.40.34 PM

2. Enter your application name
Screen Shot 2014-11-01 at 8.44.04 PM

3. click next selecting the appropriate device
4. select the application name and unselect the device orientation landscape left and landscape right

Screen Shot 2014-11-01 at 8.47.01 PM

Screen Shot 2014-11-01 at 8.47.20 PM

Screen Shot 2014-11-01 at 8.47.31 PM

5.click on the view controller then go to the first tab (file inspector), then unselect “use Auto Layout”

Screen Shot 2014-11-01 at 8.55.44 PM

6. Similarly go to the fourth tab (simulated Metrics), select the size as freeform.

Screen Shot 2014-11-01 at 8.57.58 PM

7. Now click on the view just below the view controller , select the measurement tab on the right hand side, then increase the height and fix the width as per your requirement.

Screen Shot 2014-11-01 at 9.01.44 PM

8. Now using the object library, drag the scroll view to the storyboard within view.

Screen Shot 2014-11-01 at 9.05.23 PM

9. Now go to viewcontroller.h and add the following code for scrollview

@interface ViewController : UIViewController
{
    IBOutlet UIScrollView *scroller;
}
@end

You can view above code in below image:

Screen Shot 2014-11-01 at 9.15.19 PM

10. Now go to viewcontroller.m and within viewDidload enable scrollview to yes.

@interface ViewController ()

@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    [scroller setScrollEnabled:YES];
    [scroller setContentSize:CGSizeMake(320, 568)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end

Above code is shown clearly in the below image:

Screen Shot 2014-11-01 at 9.21.31 PM

Now you are almost done with the tutorial.

11. Now go to storyboard.
12. Add some controls like label at the top and extreme bottom to get scrollview effect.

Screen Shot 2014-11-01 at 9.26.34 PM

13. Now finally click on the view controller then go to the sixth tab (Connections inspector) , there you find the outlets defined earlier by us.

14. Now drag the scrollview outlet ie, scroller to the scrollview of the storyboard

15. Then finally you get scroller referencing view controller as shown in below figure.

Screen Shot 2014-11-02 at 12.52.22 AM

16. Now run the project and you get scrolling effect in your application

Enjoy Coding

What is Phone Gap ?

Phone gap is a free and open source framework that allows to build native application against different mobile platforms. It uses knowledge of html,css and javascript. Thorough javascript we can access the phone gap api to access device features like camera, microphone etc.

Disadvantages of phone gap.

  • it does not support php.
  • There is no direct connection with mysql.
  • Api varies slightly from platform to platform

Basics Of C#

What are built in data types in C#?

  • Boolean Type -only true or false
  • Integer Type -sbyte, byte,short,int,uint,long, ulong, char
  • Floating Type – float and double
  • Decimal Type
  • String type

What is verbatim literal?

Verbatim literal is a string with an @symbol prefix as @”hello user”.It makes escape sequences translate as normal printable characters.

When we put @ symbol in front of string, all the escape symbols within string are no longer treated as escape sequence, but are treated as regular normal printable characters.eg
string name="c:\\users\\mydoc";
Console.WriteLine(name);
gives output as :

verbatim

In above fig, first backslash acts as a escape sequence so, it prints another backslash just as a character. But if you want entire url to be same, you need to use verbatim literal “@”. as shown below.

string name=@"c:\\users\\mydoc"
gives us same output without treating backslash as escape sequence.

verbatim-same

Send mail in C#

Here is the code snippet which allows you to send mail in c#

public void SendEmail()
{
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
try
{
MailAddress fromAddress = new MailAddress(“Your Email ID”, “Email Received”);
message.From = fromAddress;
message.To.Add(“Recepient email id”);
message.IsBodyHtml = true;

message.Bcc.Add(“Carbon copy email id”);
message.Subject = “Contact us info”;
message.IsBodyHtml = true;
message.Body = “ Hello!!!! ” + “Overseas Administrator” + “
” + “Contact Us information” + “

” + “Name: ” + txtyourname.Text + “
” + “Company Name: ” + txtemail.Text + “
” + “Email: ” + txtyoursubject.Text + “
” + “Message: ” + txtyoursubject.Text;
smtpClient.Host = “mail.omnis.com”; // We use gmail as our smtp client
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential(“your gmail id”, “gmail password”);

smtpClient.Send(message);

}
catch (Exception ex)
{
msg = ex.Message;
}

}