Я студентка. У меня были некоторые вопросы, связанные с встраиванием jQuery в пользовательский элемент управления на стороне сервера ASP.NET.
приватная строка GetEmbeddedTextFile (строка sTextFile)
{
// универсальная функция для извлечения содержимого
// встроенного ресурса текстового файла в виде строки
// we'll get the executing assembly, and derive
// the namespace using the first type in the assembly
Assembly a = Assembly.GetExecutingAssembly();
String sNamespace = a.GetTypes()[0].Namespace;
// with the assembly and namespace, we'll get the
// embedded resource as a stream
Stream s = a.GetManifestResourceStream(
string.Format("{0}.{1}",a.GetName().Name, sTextFile)
);
// read the contents of the stream into a string
StreamReader sr = new StreamReader(s);
String sContents = sr.ReadToEnd();
sr.Close();
s.Close();
return sContents;
}
private void RegisterJavascriptFromResource()
{
// load the embedded text file "javascript.txt"
// and register its contents as client-side script
string sScript = GetEmbeddedTextFile("JScript.txt");
this.Page.RegisterClientScriptBlock("PleaseWaitButtonScript", sScript);
}
private void RegisterJQueryFromResource()
{
// load the embedded text file "javascript.txt"
// and register its contents as client-side script
string sScript = GetEmbeddedTextFile("jquery-1.4.1.min.txt");
this.Page.ClientScript.RegisterClientScriptBlock(typeof(string), "jQuery", sScript);
// this.Page.RegisterClientScriptBlock("JQueryResourceFile", sScript);
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
// the client-side javascript code is kept
// in an embedded resource; load the script
// and register it with the page.
RegisterJQueryFromResource();
RegisterJavascriptFromResource();
}
но проблема , с которой я сталкиваюсь, заключается в том, что весь мой код JQuery, который я написал в отдельном файле .JS и попытался встроить в свой пользовательский элемент управления, передается в виде вывода на экран. Кроме того, мой элемент управления работает неправильно, как и должно быть, функциональность jQuery не работает из-за этой причины неправильного внедрения :-(
Пожалуйста, помогите мне!
Спасибо!