Write an Article Write a Tutorial Add a Fast Code* *Fast Code might be any helpful code with brief comment
Stem Cells Blood Banks Insurances .Net Hosting Credit Cards PC Rental Business
Tutorials: ASP .NET C# .NET VB .NET Articles: ASP .NET C# .NET VB .NET Fast Code: ASP .NET C# .NET VB .NET
With the introduction of ASP .NET 2.0 many programers are having problem with insertion of Javascript to the page. We will discribe here a short over view of new way to insert a dynamic Javascript in to your page. This short article is kind of extension to a detailed KB at MSDN - Using JavaScript Along with ASP.NET 2.0. Here we are discribing a new factor which rises with the unique Id of a web control.
<input id="TextBox1" runat="server" type="text" /> <Button ID="Button1" runat="server">CopyButton>
These both Html Web Controls are embedded in to asp:Content i.e We are using Master Page. Now we are going to Add/Insert the JavaScript at Page_Load event of our Page.
Button1.Attributes.Add("onclick", @"CopiedTxt = document.getElementById('" + TextBox1.UniqueID + @"').value; window.clipboardData.setData('text',CopiedTxt);");
Page.ClientScript.RegisterStartupScript(this.GetType(),"myjavascript1" , @"function PasteIt(){ CopiedTxt = document.getElementById('" + TextBox1.UniqueID + @"').value; window.clipboardData.setData('text',CopiedTxt); }",true);
ClientScript is a new Object introduce in ASP .NET 2.0. Before ASP.NET 2.0, you would have needed to employ the RegisterStartupScript and the RegisterClientScriptBlock methods. These methods are now considered obsolete. Both of these possibilities for registering scripts in ASP.NET 1.x required a key/script set of parameters. Because two separate methods were involved, there was an extreme possibility that some key name collisions would occur. The Page.ClientScript property is meant to bring all the script registrations under one umbrella, making your code less error prone.
very nice article
19/06/2007 01:22:15 UTC
19/06/2007 12:28:53 UTC
03/07/2007 11:56:51 UTC
30/07/2007 07:02:36 UTC
31/08/2007 04:43:26 UTC
17/10/2007 22:33:27 UTC
I've method for comparing two textboxes' values..have written a javascript code which checks for the larger value. As u explained above, its possible from the code behind..
i want to call a javascript on textbox' "OnBlur" method, which passes id of two textboxes....but its not taking the ids ..plz check the code given below
<asp:TextBox ID="txtPrevMilAV" onblur="javascript:return MileageValidation(this, '<%= txtCurMilAV.ClientID %>');">asp:TextBox>
18/10/2007 04:27:41 UTC
Can you also Past your JavaScript function MileageValidation()?
try this way to call the funtion:
<asp:TextBox ID="txtPrevMilAV" onblur="MileageValidation(this, '');">asp:TextBox>
if above function is correctly coded then it must work!
18/10/2007 09:04:36 UTC
23/12/2007 17:02:30 UTC
hi this is puru. ur article is userful to me
thanks
17/01/2008 02:48:04 UTC
hi i am dharmeen , this article helped me lot .
Thanks
15/04/2008 08:47:04 UTC
25/07/2008 13:56:43 UTC