Skip to content

Problem with javascript and reload page

shahid

Asked Aug 13, 2008, 11:53 AM EDT3 answers
Share
LinkedInX
i have two problem

1. how to call a javascript function from form page and also how to call c# function from javascript because when user click on button i want to validate field of form and if validation is correct then call to c# function .
please any no about this reply

2. in second i have button when i click on button a calender shown and i collect date but problem is when i click on button i page reload , i want to stop reloading of page

in coding i set the value of calender visible true
please any body no about answer reply me

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    u can't directly call C# func in javascript wht u can do is
    On button click call javascript function say
    <script lagnuage="javascript" type="text/javascript">
    function urfunname()
    {
    }
    </Script>
    on button click use onClientClick method ( Vs 2005)
    <asp:button runat="server" id="btn" OnClick="btn_click" onClientClick="javascript:urfunname()"/>
     
    if u unable to get Onclientclick
    add in form load evnet like
    Button1.Attribute.Add("onclick","urfunname()")
    this will validate ur func in javascript and if u validated then only it will go in C# code else not
    0
  • 0
    for ur 2nd problme
    same u use javascript only
    to open ur calender on click on button call javascript and open calender control this will not refresh ur page
     
    If u have any problem mail back to me @ [email protected]
    0