Thursday, 29 November 2012

read and write data into xml using gridview


//creation of gridview

<table width="900px">
                <tr>
                    <td style="background-color: Silver; width: 900">
                        <asp:GridView ID="gvClientTestimonials" runat="server" AutoGenerateColumns="false"
                            OnRowDataBound="gvClientTestimonials_RowDataBound">
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <p>
                                            <img src="images/open-quotes.gif" width="19" height="12" hspace="5" vspace="5" align="bottom"><asp:Label
                                                ID="lblTestimonial" runat="server">
                                            </asp:Label>
                                            <img src="images/close-quotes1.gif" width="19" height="12" hspace="5" vspace="5"
                                                align="middle"></p>
                                        <div align="right">
                                            <strong>--<asp:Label ID="lblClientName" runat="server"></asp:Label></strong></div>
                                        <br />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>
            </table>

//in.cs file


protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                DataSet ds = new DataSet("Testimonials");
                //finding xml file is exist or not

                if (File.Exists(Server.MapPath("Testimonials.xml")) == false)
                {                  
                    ds.Tables.Add("Testimonials");
                    ds.Tables[0].Columns.Add("Id");
                    ds.Tables[0].Columns.Add("Testimonial");
                    ds.Tables[0].Columns.Add("Client");
                    ds.Tables[0].Columns.Add("DateTime");
                   // ds.Tables[0].Rows.Add(txtClientTestimonials.Text, txtClientName.Text, DateTime.Now.ToString());
                    ds.Tables[0].Rows.Add(0, "Working with the some is a great pleasure!", "ram", DateTime.Now.ToString());
                    ds.WriteXml(Server.MapPath("ClientTestimonials/Testimonials.xml"));
                    ds.Clear();
                    ds.ReadXml(Server.MapPath("ClientTestimonials/Testimonials.xml"));
                    gvClientTestimonials.DataSource = ds;
                    gvClientTestimonials.DataBind();
                }
                else
                {
                    ds.ReadXml(Server.MapPath("ClientTestimonials/Testimonials.xml"));
                    gvClientTestimonials.DataSource = ds;
                    gvClientTestimonials.DataBind();
                }
               
            }
           
        }
        protected void gvClientTestimonials_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lblTestimonial = (Label)e.Row.FindControl("lblTestimonial");
                Label lblClientName = (Label)e.Row.FindControl("lblClientName");
                DataRowView drv = (DataRowView)e.Row.DataItem;
                lblTestimonial.Text = drv["Testimonial"].ToString();
                lblClientName.Text = drv["Client"].ToString();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet("Testimonials");
            if (File.Exists(Server.MapPath("ClientTestimonials/Testimonials.xml")) == false)
            {
                ds.Tables.Add("Testimonials");
                ds.Tables[0].Columns.Add("Id");
                ds.Tables[0].Columns.Add("Testimonial");
                ds.Tables[0].Columns.Add("Client");
                ds.Tables[0].Columns.Add("DateTime");              
                ds.Tables[0].Rows.Add(0,"Working with the Roopasoft is a great pleasure!","James",DateTime.Now.ToString());
                ds.WriteXml(Server.MapPath("ClientTestimonials/Testimonials.xml"));
            }
            else
            {
                ds.ReadXml(Server.MapPath("ClientTestimonials/Testimonials.xml"));
                ds.Tables[0].Rows.Add(ds.Tables[0].Rows.Count+1,txtClientTestimonials.Text, txtClientName.Text, DateTime.Now.ToString());
                ds.WriteXml(Server.MapPath("ClientTestimonials/Testimonials.xml"));
            }
            gvClientTestimonials.DataSource = ds;
            gvClientTestimonials.DataBind();
        }
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            txtClientName.Text = "";
            txtClientTestimonials.Text = "";

        }

Sunday, 18 November 2012

create binary image converstion and stores in database


//on button click(browse button)

private void btnProductVariantBrowse_Click(object sender, EventArgs e)
        {
  //it stores the file name in textbox
            txtProductImage.Text = BrowseFile();
         
        }

//it open window and return the file name

public string BrowseFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.RestoreDirectory = true;
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return ofd.FileName;
            }
            return "";
        }
//picture details


 if (File.Exists(txtProductImage.Text))
            {
                FileInfo fi = new FileInfo(txtProductImage.Text);
                pvDetails.picture = new Picture();
                pvDetails.picture.PictureBinary = DbHelper.FileToByteArray(txtProductImage.Text);
                pvDetails .picture .MimeType="Image/" + fi.Extension.Substring(1, fi.Extension.Length - 1);
                pvDetails .picture.IsNew =true;       
               

            }
           

//file to byte array class


 public static byte[] FileToByteArray(string _FileName)
        {
            byte[] bytArrData = null;
            try
            {
                // Open file for reading
                System.IO.FileStream _FileStream = new System.IO.FileStream(_FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                // attach filestream to binary reader
                System.IO.BinaryReader _BinaryReader = new System.IO.BinaryReader(_FileStream);
                // get total byte length of the file
                long _TotalBytes = new System.IO.FileInfo(_FileName).Length;
                // read entire file into buffer
                bytArrData = _BinaryReader.ReadBytes((Int32)_TotalBytes);

                // close file reader
                _FileStream.Close();
                _FileStream.Dispose();
                _BinaryReader.Close();
            }
            catch (Exception ex)
            {
                // Error
                //Console.WriteLine("Exception caught in process: {0}", _Exception.ToString());
            }
            return bytArrData;
        }



web editor in windows form


        private void frmPrdouctVariant_Load(object sender, EventArgs e)
        {
            _objMdiMalta = (mdiAMalta)this.MdiParent;

            ClearProductDetails();
            wbFullDescription.Navigate(Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", string.Empty) + "\\tinymce\\examples\\HtmlEditor.html");

        }
        public string HtmlFullDescription
        {
            get
            {
                string content = string.Empty;
                if (wbFullDescription.Document != null)
                {
                    object html = wbFullDescription.Document.InvokeScript("GetContent");
                    content = html as string;
                }
                return content;
            }
            set
            {
                if (wbFullDescription.Document != null)
                {
                    wbFullDescription.Document.InvokeScript("SetContent", new object[] { value });
                    // wbFullDescription.DocumentText = wbFullDescription.DocumentText.Replace("@@content@@", value);
                }
            }
        }

      public void CreateHtmlEditor(String strContent)
        {
            // String strFilePath = AppDomain.CurrentDomain.BaseDirectory + "tinymce\\examples\\index.html";
            String strBasePath = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", string.Empty);
            String strFilePath = strBasePath + "\\tinymce\\examples\\index.html";
            if (File.Exists(strFilePath))
            {
                String strFileContent = File.ReadAllText(strFilePath);

                strFileContent = strFileContent.Replace("@@content@@", strContent);
                if (File.Exists(strBasePath + "\\tinymce\\examples\\HtmlEditor.html"))
                {
                    File.Delete(strBasePath + "\\tinymce\\examples\\HtmlEditor.html");
                }
                File.WriteAllText(strBasePath + "\\tinymce\\examples\\HtmlEditor.html", strFileContent);
            }
        }

Add two gridview column deatils to one gridview column


 <div style="background-color: White; height: 600px; overflow-y: scroll;">
                <asp:GridView ID="gvCategory" runat="server" AutoGenerateColumns="false"
                    Width="200px" Height="90%"
                    OnPageIndexChanging="gvSuppliers_PageIndexChanging1"
                    onrowdatabound="gvCategory_RowDataBound">
                    <Columns>
                        <asp:TemplateField HeaderText="Category names">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtnCategory" runat="server"  CommandArgument='<%#Eval("CategoryID") %>'
                                    OnClick="lbtnCategory_Click"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <PagerSettings Mode="NumericFirstLast" />
                </asp:GridView>
            </div>


  protected void lbtnCategory_Click(object sender, EventArgs e)
         {
             LinkButton lbtnSupplier = (LinkButton)sender;
             int categoryid = int.Parse(lbtnSupplier.CommandArgument);
             int intSupplierID = Convert.ToInt32(Session["intSupplierID"]);
             BindProductGrid(intSupplierID, categoryid);
          }

          protected void gvCategory_RowDataBound(object sender, GridViewRowEventArgs e)
          {
              if (e.Row.RowType == DataControlRowType.DataRow)
              {
                LinkButton lbtn= (LinkButton) e.Row.FindControl("lbtnCategory");
                //Text='"<%#Eval("Name")"+"("+Eval("ProductCount")%>+")"'
                DataRow rowView = ((DataRowView)e.Row.DataItem).Row;
               
                if (lbtn != null)
                {
                    lbtn.Text = rowView["Name"] + " (" +  rowView["ProductCount"] + ")";
                }
              }
          }
     

Saturday, 29 September 2012

Test Credit Card Account Numbers


Test Credit Card Account Numbers

Credit Card Type
Credit Card Number
American Express
378282246310005
American Express
371449635398431
American Express Corporate
378734493671000
Australian BankCard
5610591081018250
Diners Club
30569309025904
Diners Club
38520000023237
Discover
6011111111111117
Discover
6011000990139424
JCB
3530111333300000
JCB
3566002020360505
MasterCard
5555555555554444
MasterCard
5105105105105100
Visa
4111111111111111
Visa
4012888888881881
Visa
4222222222222
Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number.
Processor-specific Cards
Dankort (PBS)
76009244561
Dankort (PBS)
5019717010103742
Switch/Solo (Paymentech)
6331101999990016

Wednesday, 26 September 2012

Ajax model pop up


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="samplemodel.aspx.cs" Inherits="vScreenSite.pages.samplemodel" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">

.ModalPopupBG
{
    background-color: #666699;
    filter: alpha(opacity=50);
    opacity: 0.7;
}

.HellowWorldPopup
{
    min-width:200px;
    min-height:150px;
    background:white;
}
    </style>
</head>
<body>
    <form id="form1" runat="server">
 <cc1:ToolkitScriptManager ID="tlkt1" runat="server">
                </cc1:ToolkitScriptManager>
<%--<asp:button id="Button1" runat="server" text="Button" />--%>

<%--<cc1:modalpopupextender id="ModalPopupExtender1" runat="server"
cancelcontrolid="btnCancel" okcontrolid="btnOkay"
targetcontrolid="Button1" popupcontrolid="Panel1"
popupdraghandlecontrolid="PopupHeader" drag="true"
backgroundcssclass="ModalPopupBG">
</cc1:modalpopupextender>--%>



<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnLogin1" runat="server" Text="Already have an account? Log in." OnClick="btnLogin1_Click" />
        <asp:Button ID="BtnTarget" runat="server" Text="Target" Style="display: none" />
       
        <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="BtnTarget"
            PopupControlID="Panel1">
        </cc1:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" BackColor="WhiteSmoke" Width="300px" Height="200px">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                <ContentTemplate>
                <table>
                <tr>
                <td>
                    <asp:Label ID="lblEmail" runat="server" Text="enter id value"></asp:Label>
                </td>
                <td>
                 <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                </td>
                 
                </tr>
                <tr>
                <td><asp:Label ID="lblPassword" runat="server" Text="enter pass value"></asp:Label>
             
                </td>
                <td><asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
                </td>
                </tr>
                </table>
                <asp:Label ID="lbl" runat="server" ></asp:Label>
               
                    <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnLogin" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </asp:Panel>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnLogin1" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>
    </form>
</body>
</html>

codebehind file code

    protected void btnLogin1_Click(object sender, EventArgs e)
        {
            ModalPopupExtender1.Show();
            txtEmail.Text = "sai";
            txtPassword.Text = "babu";
     
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtEmail.Text == "sai" && txtPassword.Text == "babu")
            {
                Response.Redirect("child_login.aspx");
            }
            else
            {
                ModalPopupExtender1.Show();
                lbl.Text = txtEmail.Text;
            }
          //  Response.Write(TextBox1.Text+" and "+TextBox2.Text);
          //  Response.Redirect("child_login.aspx");
        }
    }



Monday, 24 September 2012

facebook share


 <script>
        function fbs_click()
         {
            u = location.href;
            t = document.title;
         window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436'); return false; }</script>
    <style>
        html .fb_share_link
        {
            padding: 2px 0 0 20px;
            height: 16px;
            background: url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top left;
        }
    </style>
    <a rel="nofollow" href="http://www.facebook.com/share.php?u=>" onclick="return fbs_click()"
        target="_blank" class="fb_share_link">Share on Facebook</a>