Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to embed jquery library in asp.net custom server control?
    primarykey
    data
    text
    <p>I emebeded jquery library in custom server control. but it's not working. it throws "object expected error". the complete code listing is given below.</p> <p>jquery-1.4.1.js is rename it to jquery.js</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace ServerControl1 { [DefaultProperty("Text")] [ToolboxData("&lt;{0}:ServerControl1 runat=server&gt;&lt;/{0}:ServerControl1&gt;")] public class ServerControl1 : WebControl { [Bindable(true)] [Category("Appearance")] [DefaultValue("")] [Localizable(true)] public string Text { get { String s = (String)ViewState["Text"]; return ((s == null) ? "[" + this.ID + "]" : s); } set { ViewState["Text"] = value; } } protected override void RenderContents(HtmlTextWriter output) { output.Write("&lt;p&gt;Hello World!!&lt;/p&gt;"); } public static void RegisterJQuery(ClientScriptManager cs) { cs.RegisterClientScriptResource(typeof(ServerControl1), "ServerControl1.Resources.jquery.js"); } protected override void OnPreRender(EventArgs e) { if (!this.DesignMode) { // Register the JavaScript libraries ClientScriptManager cs = this.Page.ClientScript; ServerControl1.RegisterJQuery(cs); } } protected override void OnInit(EventArgs e) { string javascript = "&lt;script type='text/javascript'&gt; " + "$(document).ready(function () { " + "alert($('p').text()); " + "});&lt;/script&gt;"; if (!(Page.ClientScript.IsClientScriptBlockRegistered("bhelp"))) Page.ClientScript.RegisterStartupScript(this.GetType(), "bhelp", javascript); base.OnInit(e); } } } [assembly: System.Web.UI.WebResource("ServerControl1.Resources.jquery.js", "text/javascript")] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload