... 메소드 내부에서 javascript 함수를 호출하려면 어떻게해야합니까? 나는 내부입니다
public class bgchange : IMapServerDropDownBoxAction
{
void IServerAction.ServerAction(ToolbarItemInfo info)
{
Some code...
및 "일부 코드는"내가 원하는 이후
몇 가지 자바 스크립트를 트리거[WebMethod]
public static void DoSome()
{
}
를 트리거합니다. 이것이 가능한가?
여기에서 전환 방법을 확인하십시오. dosome()을 호출 할 수있었습니다. 해고했지만 자바 스크립트를 실행하지 않았다. registerstartupscript 메서드를 사용하려고했지만 구현 방법을 완전히 이해하지 못했습니다. 여기에 내가 시도 내용은 다음과 같습니다
public class bgchange : IMapServerDropDownBoxAction
{
void IServerAction.ServerAction(ToolbarItemInfo info)
{
...my C# code to perform on dropdown selection...
//now I want to trigger some javascript...
// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
String cstext1 = "alert('Hello World');";
cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}
}
}
은 내가 MSDN의 예제에서 registerstartupscript 코드를 얻었다. 분명히 올바르게 구현하고 있지 않습니다. 현재 vs는 "비 정적 필드, 메소드 또는 속성 'System.Web.UI.Page.ClientScript.get'에 대해 객체 참조가 필요합니다. Page.Clientscript;"Page.Clientscript; 코드 조각을 참조합니다.
당신이 무엇을하고 싶어하는지 더 많이 알 수 있습니까? 너 건축 같은거야? 그리고 당신이 고위층에서 공범자가되기를 원하는 것은 무엇입니까? –
DoSome()이 "JavaScript를 트리거하는"이란 무엇을 의미합니까? –