Monday, 13 August 2012

How to call JavaScript function on Code Behind or .Cs Page

function Randomn()
        {
            var  RN=Math.floor(Math.random()*99999);
                while (String(RN).length <5) { 
                 RN='0'+RN;
             }
                                                       document.getElementById('<%=txtshowtime1.ClientID%>').value=RN;                                 
                 return false;

          }

whee txtshowtime1 is textbox id in .aspx Page

Call this function on page load
Afetr the page Post Back if u uselike below
  if (!Page.IsPostBack)
        {
            populateMovieName();
            populateMultiplexName();
        }
  btnSubmit.Attributes.Add("onclick", "Randomn()");



hope this will help you.
ROHIT KUMAR SRIVASTAVA

No comments:

Post a Comment