لا يتم عرض مربع تنبيه JavaScript من خلال الرمز خلف الملف C #

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/100420

سؤال

أحتاج إلى تطبيق وظائف أولية يجب علي إظهار برنامج نصي جافا من التعليمات البرمجية خلف الملف ثم يحتاج المستخدم إلى إعادة توجيهها إلى صفحة أخرى.

لقد استخدمت كل من giveacodicetagpre.

و giveacodicetagpre.

ولكن لا يظهر أي منها مربع التنبيه مقتطف الكود هو: giveacodicetagpre.

ولكن لا أحد منهم يظهر مربع التنبيه

الرجاء مساعدتي

هل كانت مفيدة؟

المحلول

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);

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top