Thursday, June 30, 2011

Wednesday, June 29, 2011

download excel sheet/video/any thing from folder in the solution


// just writ this code under button click:

 protected void Button1_Click(object sender, EventArgs e)
    {
        string filename = "qtn.txt";//file name which used to download
        string filepath = "README.txt";//where you want to download the file
        Response.Clear();
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
        Response.ContentType = "application//octet-stream";
        Response.TransmitFile(Server.MapPath(filepath));
        Response.End();
    }

Friday, June 24, 2011

Bloc Ui code

design
---------- 
div.blockOverlay {
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; 
    filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50); 
    -moz-opacity:.70;
    opacity:.70;
    background-color: #FFFFFF;
}



 $.blockUI.defaults.overlayCSS = {};
        $.blockUI({
            message: "<img src='images/loading.gif' />",
            css: { border: '0px ',
                backgroundColor: 'Transparent',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
        });


                $.unblockUI();


<script src="Scripts/jquery.blockUI.js" type="text/javascript"></script>

get alerts fron .cs file in asp.net

 put this class in app_code folder save with the name Alert.cs

using System.Web;
using System.Text;
using System.Web.UI;

/// <summary>
/// A JavaScript alert
/// </summary>
public static class Alert
{

  /// <summary>
  /// Shows a client-side JavaScript alert in the browser.
  /// </summary>
  /// <param name="message">The message to appear in the alert.</param>
  public static void Show(string message)
  {
    // Cleans the message to allow single quotation marks
    string cleanMessage = message.Replace("'", "\\'");
    string script = "<script type=\"text/javascript\">alert('" + cleanMessage + "');</script>";

    // Gets the executing web page
    Page page = HttpContext.Current.CurrentHandler as Page;

    // Checks if the handler is a Page and that the script isn't allready on the Page
    if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
    {
      page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script);
    }
  }
   
}

Tuesday, June 21, 2011

calling .cs method from javascript

http://decoding.wordpress.com/2008/11/14/aspnet-how-to-call-a-server-side-method-from-client-side-javascript/

calling javascript function from c#code

<script>
function hi(var someVar)
{
   document.write("hi " + someVar);
}
</script>

in .NET on a method you wish to call the javascript method from:
string whatever = "blahblah";
Page.RegisterStartupScript("myScript", "<script language=JavaScript>hi('" + whatever + "');</script>");

I hope that is what you are looking for and hope it helps!

Wednesday, June 8, 2011

validation sourse code





make sure write onclick function <form tag in method attr> instead on button submit onclick



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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <title>JQuery Validation Engine</title>
        <link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css"/>
        <link rel="stylesheet" href="../css/template.css" type="text/css"/>
        <script src="../js/jquery-1.6.min.js" type="text/javascript">
        </script>
        <script src="../js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8">
        </script>

        <script src="../js/jquery.validationEngine.js" type="text/javascript" charset="utf-8">
        </script>
        <script>
            jQuery(document).ready(function() {
                // binds form submission and fields to the validation engine
                jQuery("#formID").validationEngine();
            });

            function hello() {

                alert('hiiii');
            }
        </script>
    </head>
    <body>
   
        <div calss="viv">
        <form id="formID" class="formular" method="post" action="javascript:hello()">
       
       
          <fieldset>
                <legend>
                    Text field
                </legend>
                <label>
                    URL begin with http:// https:// or ftp://
                    <br/>
                    <span>Enter a URL : </span>
                    <input value="http://" class="validate[required,custom[url]] text-input" type="text" name="url" id="url" />

                </label>
            </fieldset>
           
           <table>
           <tr>
           <td>
           name
           </td>
           <td><input type="text" id="tdtxt" class="validate[required]"  /></td>
           </tr>
          
           <tr>
           <td>
            <select name="sport" id="sport" class="validate[required]">
                        <option value="">Choose a sport</option>
                        <option value="option1">Tennis</option>
                        <option value="option2">Football</option>
                        <option value="option3">Golf</option>
                    </select>
           </td>
           </tr>
           </table>
       
       
       
       
       
            <input class="submit" type="submit" value="Validate & Send the form!"/>
            <hr/>
        </form>
</div>
    </body>
</html>

jQuery Plugins that enhance and beautify HTML form elements and validations

http://www.queness.com/post/204/25-jquery-plugins-that-enhance-and-beautify-html-form-elements


http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/

Monday, June 6, 2011