저는 학부생입니다. ASP.NET 서버 측 사용자 정의 컨트롤 안에 jQuery를 포함시키는 것과 관련된 몇 가지 쿼리가있었습니다.ASP.Net 서버 사용자 정의 컨트롤에 jQuery 임베드
이개인 문자열 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();
}
같은 내용 // 포함 된 텍스트 파일 리소스를 검색하는 기능을하지만 난에 직면하고있는 문제가 별도의 .JS 파일로 작성한 내 사용자 정의 컨트롤에 포함하려고 시도한 모든 JQuery 코드가 화면에 출력으로 스트리밍됩니다. 또한 내 컨트롤이 제대로 동작하지 않아 jQuery 기능이 제대로 작동하지 않는 이유로 인해 작동하지 않습니다.