Solved

JQuery Custom Control

Posted on 2012-03-12
2
524 Views
Last Modified: 2012-03-13
I am trying to call a calender popup using custom controls which is not working

What i did

I download calender plugin shown below and run in my webpage - worked
(http://jqueryui.com/demos/datepicker/#icon-trigger)
I replaced the calendar JS and CSS files to dll - NOT WORKED
I added a Sample js and css file in the DLL and called that js and css - WORKED

Why the calender JS and css not worked?

Trials that i did
-----------------------
Changed the property to Embedded resource
Removed the DOTS from the Jquery JS files


This is the way i am calling the css:


 string cssDatePickerURL = Page.ClientScript.GetWebResourceUrl(typeof(WebDate), "Infotech3i.TSG.WebControls.WebDate.jquery.ui.datepicker.css");
 HtmlLink cssDatePicker = new HtmlLink();
cssDatePicker.Href = cssDatePickerURL;
 cssDatePicker.Attributes.Add("rel", "stylesheet");
 this.Page.Header.Controls.Add(cssDatePicker);


This is the way i am calling the JS:

  cs.RegisterClientScriptResource(typeof(WebDate), "Infotech3i.TSG.WebControls.WebDate.jquery-1.7.1.min.js");
            cs.RegisterClientScriptResource(typeof(WebDate), "Infotech3i.TSG.WebControls.WebDate.jquery.ui.core.js");
            cs.RegisterClientScriptResource(typeof(WebDate), "Infotech3i.TSG.WebControls.WebDate.jquery.ui.datepicker.js");
0
Comment
Question by:PeteEngineer
  • 2
2 Comments
 
LVL 8

Author Comment

by:PeteEngineer
ID: 37713349
CSS files are taken but Java scripts are not.

In Fire Bug , HTML tag shows <Link> tag. There are 9 link tag each for my
CSS and Js files. In those CSS links are showing data properly but JS data
is showing as below :

<title>The resource cannot be found.</title>

<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>The resource cannot be found.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.
<br><br>
<b> Requested URL: </b>/WebResource.axd<br><br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
</font>
</body>

Moreover, there is Firebug tab name CSS.

In that there is a dropdown which shows 9 webresource.axd?sfsdfsdfsdcsksdfkhskdf values where each describes the js and css files embedded as resource.

in those CSS resources are look fine, but for js nothing is visible and a blank page comes in the firebug console while i click

I have found following following trials to fix this issue : But no hope :-(

Added [assembly: WebResource("MyNamespace.MyScriptFile.js", "text/javascript")] above the class's namespace declaration.
Script file has build action "Embedded Resource".
Tried registering during OnInit, OnLoad and OnPreRender
Script file is in the same assembly and namespace as the control registering it its work fine.

Does not work using any of the following methods:
ScriptManager.RegisterClientScriptResource(Page, GetType(), "MyNamespace.MyScriptFile.js");


Page.ClientScript.RegisterClientScriptResource(GetType(), "MyNamespace.MyScriptFile.js");



Try implementing my own ScriptManger and then adding the embedded file from there. Here's an example

public class MyScriptManager : System.Web.UI.ScriptManager
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
RegisterClientScriptResource(this, typeof(ScriptManagerExtension), "MyNamespace.MyScriptFile.js");
}

typeof(WebDate)


[assembly: WebResource("Library.Resources.Scripts.libscript.js", "text/javascript", PerformSubstitution = true)]

Changed the order of js files

.BaseType

typeof(Company.Product.Web.Library.Class1)

Created Different solution for dll

Please help any other alternatives available?
0
 
LVL 8

Accepted Solution

by:
PeteEngineer earned 0 total points
ID: 37713887
Thanks God !!


Issue got fixed :

I issue was .i was using  javascript in the website which i was calling and was using
wrong client ID ..but when i embedded in the dll its working like below :

 string javascript = "<script type='text/jscript'> " +
                                 "$(document).ready(function () { " +
                                 "$('" + "#" + this.ClientID + "').datepicker(); " +
                                 "});</script>";

            Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID, javascript);


Thanks for the help !
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now