Solved

How to combine Javascript with ASP.Net

Posted on 2006-06-28
1
489 Views
Last Modified: 2008-02-26
I want to call the following in  a ASP.net form, but it gives me error.

<input type="text" value="2004/02/02" readonly name="theDate">
<input type="button" value="Cal" onclick="displayCalendar(document.forms[0].theDate,'yyyy/mm/dd',this)">


I also tried to modifiy the above code to the following, but still doesnt work.
<asp:TextBox Runat=server ID="theDate" ></asp:TextBox>
            <asp:Button id="tt" Runat=server Text="Cal"></asp:Button>
in C# code,       

      private void Page_Load(object sender, System.EventArgs e)
      {
      tt.Attributes.Add("onclick","displayCalendar(document.getElementById('theDate').value,'yyyy/mm/dd',this);");

....

}
0
Comment
Question by:yk99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 250 total points
ID: 17002113
input type="text" value="2004/02/02" readonly name="theDate">
<input type="button" value="Cal" onclick="displayCalendar(document.forms[0].theDate,'yyyy/mm/dd',this);"> --put semicolen after )

<asp:TextBox Runat=server ID="theDate" ></asp:TextBox>
          <asp:Button id="tt" Runat=server Text="Cal"></asp:Button>
in C# code,      

     private void Page_Load(object sender, System.EventArgs e)
     {
     tt.Attributes.Add("onclick()","displayCalendar(document.getElementById('theDate').value,'yyyy/mm/dd',this);");

....

}
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question