Wednesday, 26 December 2012

gridview data download in asp.net


gridview print as design show on the form
in asp.net.


you can   download the show data on grid or listview or any control in aps.net. just change bold and underline.

 protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Clear();
            Response.AddHeader("content-disposition", "attachment;filename=myexcelfile.doc");
            Response.ContentType = "application/vnd.xls";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            GridView1.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();
        }
        public override void VerifyRenderingInServerForm(Control control)
        {
            //base.VerifyRenderingInServerForm(control);
        }

Friday, 21 December 2012

Image code with sql server


Image Insert /Retrieve  with  sql server Database Table
Asp.net code insert image by  code
cmd.Parameters.Add("@ProductPicture", SqlDbType.VarBinary).Value = uploadProduct.FileBytes;

retrieve image from sql server databse
we take new asp.net page and convert byte to response. BinaryWrite

<asp:Image ID="Image1" runat="server" ImageUrl='<%# "GetProductPicture.aspx?ProductID=" + Eval("ProductID")%>' alt="Image" Width="150px" Height="100px" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1" style="border-radius:5px;" />

Now productPicture page code
protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = null;
        try
        {
           int Prod_Id = Convert.ToInt32(Request.QueryString["ProductID"].ToString());
          con = new SqlConnection(ConfigurationManager.AppSettings["AsCon"].ToString());
            if (con != null)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("select ProductPicture from ProductMaster where ProductID=" + Prod_Id + "", con);
            byte[] product = (byte[])cmd.ExecuteScalar();
            Response.BinaryWrite(product);
        }
        catch (Exception ex)
        {
           // Mailer.SendTechnicalMail(ex.Message);
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }

Thursday, 20 December 2012

message box show in asp.net

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// Summary description for MessageBox
/// </summary>
public class MessageBox
{
    // Lets keep the message coming from all the pages here
    static Dictionary<Page, Queue> pageTable = null;
   
    static MessageBox()
    {
        // Create the store
        pageTable = new Dictionary<Page, Queue>();
    }

    public static void Show(string str)
    {
        // Lets find out what page is sending the request
        Page page = HttpContext.Current.Handler as Page;

        // If a valid page is found
        if (page != null)
        {
            // Check if this page is requesing message show for the first time
            if (pageTable.ContainsKey(page) == false)
            {
                // Lets create a message queue dedicated for this page.
                pageTable.Add(page, new Queue());
            }

            // Let us add messages of this to the queue now
            pageTable[page].Enqueue(str);

            // Now let put a hook on the page unload where we will show our message
            page.Unload += new EventHandler(page_Unload);
        }       
    }

    static void page_Unload(object sender, EventArgs e)
    {
        // Lets find out which page is getting unloaded
        Page page = sender as Page;

        // If a valid page is founf
        if (page != null)
        {
            // Extract the messages for this page and push them to client side
            HttpContext.Current.Response.Write("<script>alert('" + pageTable[page].Dequeue() + "');</script>");
        }
    }
}


//Pokemon exception handling
           // MessageBox.Show("Exception has occured: " + //ex.Message);



Sunday, 2 December 2012

asp.net payment Getways code

online payment getway in asp.net / vb.net

https://support.ebs.in/app/index.php?/Knowledgebase/List/Index/9


click on Integration Kits--> then download according your project code files

Extratct Zip--> Run Page pay.aspx

fill all basic information

then respose url please copy paste url local host : 7856 any no those show on your Browser

Saturday, 1 December 2012

drop all table from sql server database

drop table from sql server database

EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

other commands can u use for Alter And delete 

EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
EXEC sp_MSForEachTable 'DELETE FROM ?'
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'

key code, key press ASCII code



Press a key in the text box below to see the corresponding key code using in c# , javascript

KeyCode
backspace8
tab9
enter13
shift16
ctrl17
alt18
pause/break19
caps lock20
escape27
page up33
page down34
end35
home36
left arrow37
up arrow38
right arrow39
down arrow40
insert45
delete46
048
149
250
351
452
553
654
755
856
957
a65
b66
c67
d68
 
KeyCode
e69
f70
g71
h72
i73
j74
k75
l76
m77
n78
o79
p80
q81
r82
s83
t84
u85
v86
w87
x88
y89
z90
left window key91
right window key92
select key93
numpad 096
numpad 197
numpad 298
numpad 399
numpad 4100
numpad 5101
numpad 6102
numpad 7103
 
KeyCode
numpad 8104
numpad 9105
multiply106
add107
subtract109
decimal point110
divide111
f1112
f2113
f3114
f4115
f5116
f6117
f7118
f8119
f9120
f10121
f11122
f12123
num lock144
scroll lock145
semi-colon186
equal sign187
comma188
dash189
period190
forward slash191
grave accent192
open bracket219
back slash220
close braket221
single quote222