Tuesday, January 17, 2017

Android Pressing Back Button Should Exit The Application



Name : Uday Shah - HOD (IT)
Contact No : 7600044051

--------------------------------------------------------------------------------------------------------------------------
Android Support Back Button Function to Exit Directly From Your Android App.

In my Home Activity I override the "onBackPressed" to:

@Override
public void onBackPressed()
{
   Intent intent = new Intent(Intent.ACTION_MAIN);
   intent.addCategory(Intent.CATEGORY_HOME);
   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   startActivity(intent);
 }


------------------------------------------------------------------------------------
/**
 * Back button listener.
 * Will close the application if the back button pressed twice.
 */

int backButtonCount; // Declare as Global Variable


@Override
public void onBackPressed()
{
    if(backButtonCount >= 1)
    {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
    else
    {
        Toast.makeText(this, "Press the back button once again to close the application.", Toast.LENGTH_SHORT).show();
        backButtonCount++;
    }
}

in above code Back Button Work as Intent  and provide Intent Action. 
Thank You 

Please share in your Group

Tuesday, January 10, 2017

Dynamic Video Upload in Database and Display it using Literal Control in Asp.net with C#


Name : Uday Shah - HOD (IT)
Contact No : 7600044051
E-Mail : rupareleducation@gmail.com
-----------------------------------------------------------------
Dynamic Image Upload in Database and Display it using Literal Control in Asp.net with C#

Admin Side
Video.aspx
<table style="width: 100%">
<tr style="width: 100%">
              <td style="width: 100%" align="center" colspan="2" valign="top">
                    <h2>
                        :: Videos ::
                    </h2>
</td>
</tr>
<tr style="width: 100%">
<td style="width: 50%; text-align: right">
                    Name:
</td>
<td style="width: 50%" align="left">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr style="width: 100%">
<td style="width: 50%; text-align: right">
                    Video:
</td>
<td style="width: 50%" align="left">
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
<tr style="width: 100%">
<td style="width: 50%" align="right">
<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
</td>
<td style="width: 50%" align="left">
<asp:Button ID="Button2" runat="server" Text="Cancel" />
</td>
</tr>
</table>
-------------------------------------------------------------------------------
Video.aspx.cs
Add this Name Space 

using System.Web.Configuration;
using System.Data.SqlClient;

Button Click Event
string s = WebConfigurationManager.ConnectionStrings["cs"].ToString();
SqlConnection cn = new SqlConnection(s);
string path = Server.MapPath("~/img/" + FileUpload1.FileName);
FileUpload1.SaveAs(path);
string pic = FileUpload1.FileName.ToString();
cn.Open();
SqlCommand cmd = new SqlCommand("insert into video values('" + TextBox3.Text + "','" + pic +                            "')", cn);

cmd.ExecuteNonQuery();



Visitor Side

Videodisp.aspx

<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 100%" align="center">

                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="video" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1">
                </asp:DropDownList>

                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Video]">
</asp:SqlDataSource>

<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Button" />
            </td>
</tr>
        <tr style="width: 100%">
            <td style="width: 100%" align="center">
                <div class="borded">
                    <asp:Literal ID="Literal1" runat="server" Text=""></asp:Literal>
                </div>
            </td>
</tr>
</table>



             


Admin View

Visitor View