Wednesday, 1 July 2015

Blink a text using CSS

Blink a text using CSS

CSS:
.blink_me {
    -webkit-animation-name: blinker;
    -webkit-animation-duration: 1s;
    -webkit-animation-timing-function: linear;
    -webkit-animation-iteration-count: infinite;

    -moz-animation-name: blinker;
    -moz-animation-duration: 1s;
    -moz-animation-timing-function: linear;
    -moz-animation-iteration-count: infinite;

    animation-name: blinker;
    animation-duration: 1s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@-moz-keyframes blinker {  
    0% { opacity: 1.0; }
    50% { opacity: 0.0; }
    100% { opacity: 1.0; }
}

@-webkit-keyframes blinker {  
    0% { opacity: 1.0; }
    50% { opacity: 0.0; }
    100% { opacity: 1.0; }
}

@keyframes blinker {  
    0% { opacity: 1.0; }
    50% { opacity: 0.0; }
    100% { opacity: 1.0; }
}
 
 
HTML:
<span class="blink_me">This Will Blink</span>
 
 
 

Monday, 4 May 2015

CRUD Operations in MVC 4

CRUD Operations in MVC 4

Link: http://www.codeproject.com/Articles/695850/Complete-CRUD-Operations-in-MVC

Thursday, 16 April 2015

Disable button on click while saving/updating

Disable button on click

OnClientClick="this.disabled = true; this.value = 'Submitting...';" UseSubmitBehavior="false"

Thursday, 19 February 2015

Compare Dates in javascript, jquery

Compare Dates  in javascript, jquery   

function dateVerity() {
          var from = document.getElementById('<%=Textbox1.ClientID%>').value;
          var to = document.getElementById('<%=Textbox2.ClientID%>').value;
          var arr_From = from.split("/");
          var arr_To = to.split("/");
         
          var d1 = new Date(arr_From[2], arr_From[1]-1, arr_From[0]); // Jan 1, 2011
          var d2 = new Date(arr_To[2], arr_To[1]-1, arr_To[0]); // Jan 2, 2011
          d1.setMonth(d1.getMonth() + 3); // Adding three months
          d1.setDate(d1.getDate() -1); // Substracting 1 day
          var d11 = d1.setHours(0, 0, 0, 0); // set hours to Zero because only dates will compare
          var d22 = d2.setHours(0, 0, 0, 0); // set hours to Zero because only dates will compare
       
          if (d22 < d11) {
              alert("There should be 3 months gap between from and to date");
              return false;
          }
          else {
              return true;
          }
         
      }

Thursday, 18 December 2014

Call javascript function from code behind in C#

Call javascript function from code behind in C#


Suppose you want to call javascript function ParentRefresh() from code behind in C#.

<script type="text/javascript">
function ParentRefresh()
{
   // javascript code
}
</script>

protected void Save_Click(object sender, EventArgs e)
    {
// your save code
ScriptManager.RegisterStartupScript(this, GetType(), "message", "ParentRefresh();", true);
}

Access a parent element (Button) from iframe using c#

Access parent element (Button) from iframe using c#


Suppose you have 2 pages:
1. Parent Page: On which there is a iframe. as Parent.aspx
2. Loaded page: inside the iframe where Child.aspx is loaded

You want if you save some thing on Child.aspx (Loaded page), the grid on Parent page (Parent.aspx) will automatically refresh.  

So you make a hidden button on the Parent page (Parent.aspx)

<div style="display:none">
    <asp:Button ID="Done" runat="server" ClientIDMode="Static" OnClick="Done_Click" />
</div>

protected void Done_Click(object sender, EventArgs e)
    {
        // Refresh Grid
    }

Note that the ClientIDMode="Static" because from the other page you can not know what is the rendered id, so keep it static. If you do not use dot net 4 that have the static id, then you need to also use javascript to send the rendered id to the page, or some other way to 
locate the button.

Call a javascript function on Child.aspx (Loaded Page)

<script type="text/javascript">
function ParentRefresh()
{
   window.parent.document.getElementById('Done').click();
}
</script>

protected void Save_Click(object sender, EventArgs e)
    {
// your save code
ScriptManager.RegisterStartupScript(this, GetType(), "message", "ParentRefresh();", true);
}

Wednesday, 10 December 2014

Regular Expression for Date Format (dd/mm/yyyy) and (mm/yyyy)

Regular Expression for Date Format (dd/mm/yyyy):

(^(((0[1-9]|[12][0-8])[\/](0[1-9]|1[012]))|((29|30|31)[\/](0[13578]|1[02]))|((29|30)[\/](0[4,6,9]|11)))[\/](19|[2-9][0-9])\d\d$)|(^29[\/]02[\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)$)

Regular Expression for Date Format (mm/yyyy):

^((((((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$