Frage

Ich muss eine Funktionalität implementieren, in der zunächst Java-Skript von Code hinter der Datei angezeigt werden muss, und der Benutzer muss dann auf andere Seite weitergeleitet werden.

Ich habe beide verwendet generasacodicetagpre.

und generasacodicetagpre.

aber keiner von ihnen zeigte die Warnbox Der Code-Snippet ist als: generasacodicetagpre.

aber keiner von ihnen zeigt das Warnkasten

Bitte helfen Sie mir,

War es hilfreich?

Lösung

The script will never make it to the client because of the redirect. You either need to send the script with the alert and then postback to perform the redirect (yuck) or perform the redirect in the script by doing a location.replace to the URL you want to redirect to...you could also set location.href to the URL as well.

So you could do something like this:

ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptname", "alert('some message'");location.replace('url to redirect to');", true);

Andere Tipps

These methods registers and adds the script block to the page. So it will fire after the page is rendered from the server. In your case you are redirecting to some other page while the script is registered on the previous page.

So it would not fire on the previous page.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top