انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Redirect Users to Another Page

الكلية كلية تكنولوجيا المعلومات     القسم قسم شبكات المعلومات     المرحلة 2
أستاذ المادة حۡــسۜــنۨ ا̍ڷــڔهــٻۧــمۘــې       3/10/2012 8:15:51 PM
you might want to redirect use

You may want to redirect users from one asp.net web page to another web page. for example, you might do this as part of a multi-page form. there are a number of ways to redirect pages, such as the following:

• by configuring the page to post to another page in this scenario, the user clicks a button that you have configured to post to a different page. this scenario is useful for multi-page forms. however, it requires user interaction.( also called cross-page posting)

• by dynamically using the browser in this scenario, you send a command to the user s browser that causes the browser to retrieve a different page. this allows you to programmatically redirect to another page. however, the redirection causes a new request (an http get), and any post data from the source page is lost.

• by dynamically using a server-side method in this scenario, the server simply transfers the context to another page. the advantage is that you can share page context information between pages. the disadvantage is that the user s browser does not know about the transfer, so the browser s history is not updatingd. if the user refreshes the page, unexpected results can occur.



to redirect a user to another page by using the browser

1. set the response object s bufferoutput property to true.
2. call the response object s redirect method, passing it the url of the page to which you want to redirect users.
the following code example shows how to redirect a page based on the contents of a local variable, userlanguage, which is set elsewhere.
response.bufferoutput = true
if (userlanguage == "english")
{response.redirect("http://www.microsoft.com/gohere/look.htm") }
else if (userlanguage == "deutsch")
{response.redirect("http://www.microsoft.com/gohere/look_deu.htm") }
else if (userlanguage == "espa?ol")
{ response.redirect("http://www.microsoft.com/gohere/look_esp.htm") }



to redirect users to another page by using a server-side method

call the transfer method, passing it the name of the page to which you want to redirect users.the following code example shows how to redirect to another page.

protected void button1_click(object sender, system.eventargs e)
{
server.transfer("page2.aspx", true)
}

rare case of posting back to server

by default, buttons and other controls that cause a postback on an asp.net web page submit the page back to itself. this is part of the round-trip cycle that asp.net web pages go through as part of their normal processing
under some circumstances, you might want to post one page to another page. for example, you might be creating a multi-page form that collects different information on each page. in that case, you can configure certain controls (those that implement the ibuttoncontrol interface, such as the button control) on the page to post to a different target page. this is referred to as cross-page posting. cross-page posting provides some advantages over using the transfer method to redirect to another pagewhen you configure a page for cross-page posting, you frequently want to get information from the source page. this might include the information from controls on the page—that is, the information being posted by the browser

note : if the source and target page are in different applications, you cannot directly get the values of controls on the page, but you can read the posted data from the form dictionary.

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .