[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

JQuery Custom Control

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
PeteEngineer
Asked:
PeteEngineer
  • 2
1 Solution
 
PeteEngineerAuthor Commented:
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
 
PeteEngineerAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now