Friday, 13 July 2012

user control save

user control code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swash.Objects;
using Swash.BusinessLayer;

namespace Website.App_WebControls.UAMS_UserControls
{
    public partial class AMS_UCUSingleSelection : System.Web.UI.UserControl
    {
        public delegate void SingleSelect(List<AMS_UCUSelection> SingleRadList);
        public event SingleSelect SelectEvent;
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
        public void FillRadioList(AMS_UCUSelection objSelect)
        {
            lblHeader.Text = objSelect.HeaderText;
            RadSelect.DataSource = UERPManagement.GetInstance.GetAllSelectionDetails(objSelect);
            RadSelect.DataTextField = "Text";
            RadSelect.DataValueField = "Value";
            RadSelect.DataBind();
        }
        protected void ImgBtnAdd_Click(object sender, ImageClickEventArgs e)
        {
            List<AMS_UCUSelection> SingleChk = new List<AMS_UCUSelection>();
            foreach(ListItem li in RadSelect.Items)
            {
                if (li.Selected)
                {
                    AMS_UCUSelection obj = new AMS_UCUSelection();
                    obj.Text = li.Text;
                    obj.Value = li.Value;
                    SingleChk.Add(obj);
                    break;
                }
            }
           
            if (this.SelectEvent != null)
            {
                this.SelectEvent(SingleChk);
            }
        }
    }
}

page code:
 AMS_UCUSelection objSelect = new AMS_UCUSelection();
            objSelect.HeaderText = "Category List [Single Selection]";
            objSelect.TableName = "ams.AMS_Category";
            objSelect.Text = "CategoryName";
            objSelect.Value = "CategoryId";
            CategorySelect.FillRadioList(objSelect);

Wednesday, 11 July 2012

how to open a page using ifram and jqury popup

Code:

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

<!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>
    <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
     <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
    <style type="text/css">
    #popupBoxClose
 {
    font-size:10px;
    line-height:15px;
    right:5px;
    top:5px;
    position:absolute;
    color:#6fa5e2;
    font-weight:500;    
}
#popup_box {
    display:none;
    position:fixed;
    _position:absolute;
    height:auto;
    width:auto;
    background:#FFFFFF;
    left: 300px;
    top: 150px;
    z-index:100;
    margin-left: 15px;
    border:2px solid #999999;    
    padding:15px;
    font-size:15px;
    -moz-box-shadow: 0 0 5px #ff0000;
    -webkit-box-shadow: 0 0 5px #ff0000;
 
}

    </style>
     <script type="text/javascript">
         function x(s) {
             $('#<%=im.ClientID %>').attr('src', s);
             $('#popup_box').slideDown("slow");
          }
         $(document).ready(function () {
           
             $('#popup_box').click
             (
             function () {
                 $('#popup_box').slideUp("slow");
             }
             )
             Sys.WebForms.PageRequestManager.getInstance().add_endRequest(JqueryAction);
             JqueryAction();
         });
         function ShowPopUp() {
         
             $('#popup_box').slideDown("slow");
         }
         function JqueryAction() {
           
             $('#popupBoxClose').click(function () {
                 $('#popup_box').slideUp("slow");
             });
         }
      
</script>
</head>
<body>
    <form id="form1" runat="server">
  
<a href="#"  onclick="x('Default.aspx')" id="ab" >Press Me</a>
<div id="popup_box">
<a id="popupBoxClose" href="#">Close</a><br />
     <iframe runat="server" id="im" style="height:300px; width:600px"></iframe>
</div>


   
    </form>
</body>
</html>

Tuesday, 10 July 2012

dynamic store procedure call

ALTER PROCEDURE ams.Uselection
    (
    @TableName varchar(50),
    @Value varchar(50),
    @Text varchar(50)
    )
   
AS
declare @sql varchar(max)
BEGIN
 SET NOCOUNT ON
 set @sql=('select '+ @Value +','+ @Text +' from '+ 'ams.'+@TableName)
exec(@sql)
 set  NOCOUNT ON
END

Friday, 6 July 2012

Numaric validation in javascript

function validate(s)
         {
             var x = s.keyCode;
             var phn = document.getElementById('<%=TxtOFFZipCode.ClientID %>');
             var j = "0123456789"
             for (var i = 0; i < phn.value.length; i++) {
                
                 if (j.search(phn.value.charAt(i)) == -1) {
                     alert('Zip code  should be Numeric ');
                     phn.value = "";
                     return false;
                 }
             }

how to open a new window in javascript for ever browser

 mywindow = window.open("Default.aspx", "mywindow", "location=1,status=1,scrollbars=1, width=580,height=600,screenX=300,screenY=300");
                        mywindow.moveTo(100, 20);

how to say of text in asp.net

First add a DLL in this way


Code:
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SpeechLib;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }
    protected void btn_Click(object sender, EventArgs e)
    {
        SpVoiceClass sp = new SpVoiceClass();
        sp.Speak("jay jagannath", SpeechVoiceSpeakFlags.SVSFDefault);
    }
}