|
Redirect and Transfer both cause a new page to be processed. But the interaction between the client (web browser) and server (ASP.NET) is different in each situation.
Redirect: A redirect is just a suggestion – it’s like saying to the client “Hey, you might want to look at this”. All you tell the client is the new URL to look at, and if they comply, they do a second request for the new URL.
If you want to pass state from the source page to the new page, you have to pass it either on the URL (such as a database key, or message string), or you can store it in the Session object (caveat: there may be more than one browser window, and they’ll all use the same session object).
Transfer: A transfer happens without the client knowing – it’s the equivalent of a client requesting one page, but being given another. As far as the client knows, they are still visiting the original URL.
Sharing state between pages is much easier using Server.Transfer – you can put values into the Context.Items dictionary, which is similar to Session and Application, except that it lasts only for the current request. (search for HttpContext in MSDN). The page receiving postback can process data, store values in the Context, and then Transfer to a page that uses the values.
With Regards
Satips
|
|
|
|
|
Hi,
Have a look at Server.Transfer vs Response.Redirect[^] for your clarification.
In Brief:
Response.Redirect simply tells the browser to visit another page. Server.Transfer helps reduce server requests, keeps the URL the same and allows you to transfer the query string and form variables.
Regards,
Jay
|
|
|
|
|
Dear All,
I'm a beginner in ASP.Net and was building a asp.net application. Just wanna to ask is there any commands or functions in asp.net which can act similiarly like Application.DoEvents in windows programming? Please help. Thanks!
|
|
|
|
|
You can use client scripts i.e., java script to execute the applications by using var wshShell = new ActiveXObject("WScript.Shell"); object.
Sathik
|
|
|
|
|
Actually my web application is link to a scanner where tags/bar code goes over the scanner, the tag number will be display in a listbox. There are a DO loop in the program checking whether any tags had been scanned. If yes, the program will display the tag in a listbox. Else the program will continue to loop till the user press stop scan.
At first i thought in web application, there is functions such as Application.DoEvents which will process the event once it detect user input. Any idea on how to display tag numbers which were scanned and display it in the list box on shot without refresh the page? Please help. Thanks alot.
|
|
|
|
|
You can use a client control or server control with client script to achieve this by using AJAX
Sathik
|
|
|
|
|
Dear Sathik,
Thanks for your reply. I try using AJAX in my application but i face another problem. Is it anyway for me to execute some functions under the button.click event before calling the client script functions using Ajax? Thansk in advance.
|
|
|
|
|
How would I delete a file from the server? I haven't been able to find any code that demonstrates this...
AHA! File.Delete
|
|
|
|
|
Give this a shot:
System.IO.File.Delete(Server.MapPath("filetodelete.ext"));
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
try this
using System.IO;
path = Server.MapPath("../Client").ToString();
File.Delete(path);
|
|
|
|
|
I have master page with several panels and depending on the user configuration I load the childpages on different panels, in other words I move around the ContentPlaceHolder, now, since I started doing that some server controls started to behave strangely, for example a gridview which was working fine now when a row is selected it will say:
============================================================
SelectedDataKey null System.Web.UI.WebControls.DataKey
SelectedIndex 4 int
SelectedRow {System.Web.UI.WebControls.GridViewRow} ...
SelectedRowStyle {System.Web.UI.WebControls.TableItemStyle} ...
SelectedValue null object
============================================================
the SelectedDataKey and SelectedValue are null while SelectedRow is fine.
What happens when I add the ContentPlaceHolder to another panel that is not the original panel that contained it that makes this viewstate issue happen?
I switch the ContentPlaceHolder from panel to panel like this:
=========
PanelX.Controls.Add(mainplaceholder);
or
PanelY.Controls.Add(mainplaceholder);
=========
I'm doing this on "protected override void OnInit(EventArgs e)" of my "main.default.cs".
any help is very much appreciated!
|
|
|
|
|
ThePlagueIsBack wrote: What happens when I add the ContentPlaceHolder to another panel that is not the original panel that contained it that makes this viewstate issue happen?
Hi there. I'm sure that is in fact where a viewState issue would come in. The Panel is an INamingContainer, and child controls within a Panel would be rendered with client ID's that reflect the parent naming container.
I'm not sure I have any advice for you on what to do.
|
|
|
|
|
that makes sense however! I executed the page with the contentplaceholder on the default place and compared the html source with different panel positions and the placeholder has always the same id, every other property is identical.
|
|
|
|
|
I want to add a cancellation-confirm message to the cancel button a wizard control. I'd normally do something this if I could access the button control:
btnMyButton.Attributes.Add("onClick", "javascript:return confirm('Are you sure you want to delete the Internet?')")
Any ideas on how I can access the cancel button in the wizard control to do this? Thanks
|
|
|
|
|
Right click the Wizard component -> "Edit Template" -> "Finish Navigation Template" and create your own button set or whatever you want to put there.
sample template:
<FinishNavigationTemplate>
<asp:Panel BackColor="#E0E0E0" Width="300" Style="padding:3px" Runat="Server">
<asp:Button id="FinishPreviousButton" CommandName="MovePrevious" Text="Prev" Width="60" Runat="Server"/>
<asp:Button id="FinishButton" CommandName="MoveFinish" Text="Finish" Width="60" Runat="Server"/>
</asp:Panel>
</FinishNavigationTemplate>
|
|
|
|
|
|
hi! I have a user control, which consists of a label and a text box. I want to make validation of my user control with standard asp.net validators. I write the following:
[System.Web.UI.ValidationPropertyAttribute("TextBoxValidation")]
public class MyUserControl : System.Web.UI.UserControl
{
public string TextBoxValidation
{
get {}
set {}
}
The question is:
What should be written in the TextBoxValidation setter and getter?
Thanks in advance!
|
|
|
|
|
hi! I have a user control, which consists of a label and a text box. I want to make validation of my user control with standard asp.net validators. I write the following:
[System.Web.UI.ValidationPropertyAttribute("TextBoxValidation")]
public class MyUserControl : System.Web.UI.UserControl
{
public string TextBoxValidation
{
get {}
set {}
}
The question is:
What should be written in the TextBoxValidation setter and getter?
Thanks in advance!
|
|
|
|
|
When i try to connect to sql express database in the project i am getting this error. can anyone help me?
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Thanks annd regards
Hari
|
|
|
|
|
Have you checked the possible cause that is mentioned in the error message?
---
b { font-weight: normal; }
|
|
|
|
|
where can i correct that. i am new to sql express
|
|
|
|
|
Open the Configuration Manager and enable the protocol under Network Configuration.
---
b { font-weight: normal; }
|
|
|
|
|
Hi to all,
I'm trying to invoke a method in ASP from JScript page (OnClick or anything similar to it) on the same related .aspx page with no success.
can someone please explain me how something like that can be done?
|
|
|
|
|
I am not sure about the method but you can fire the event from java script. by using do_postback method.
Sathik
|
|
|
|
|
Hi I hope you can help me with this problem:
Checking the event viewer of a Web Application I have noticed that periodically happens a ViewState Verification fail. It happens several times by day on a diferent .aspx pages. Sometimes it causes an error and the user loses his data, but other times apparently user can continue using the application.
This is the event registered ( I have changed the computer name and the path data, but it's not importante for the question)
COMPUTER_NAME Event code: 4009 <br />
Event message: Viewstate verification failed.<br />
Reason: The viewstate supplied failed integrity check.<br />
<br />
Event time: 10/8/2006 6:54:00 PM <br />
Event time (UTC): 10/8/2006 4:54:00 PM <br />
Event ID: 78a9d00b907b4edab1ac37665fa3175c <br />
Event sequence: 447 <br />
<br />
Event occurrence: 2 Event detail code: 50203 <br />
Application information: <br />
Application domain: /LM/W3SVC/250184202/Root/ApplicationPath-1-128047877472787699 <br />
Trust level: FullApplication <br />
Virtual Path: /ApplicationName <br />
Application Path: D:\Directory\www\ ApplicationName \ <br />
Machine name: COMPUTER_NAME<br />
Process information: <br />
Process ID: 2916<br />
Process name: w3wp.exeAccount name: NT AUTHORITY\NETWORK SERVICE<br />
Request information: <br />
Request URL: http:
Request path: ApplicationName /ApplicationForm.aspx <br />
User host address: 80.66.205.47 <br />
User: USER@application.com <br />
Is authenticated: True <br />
Authentication Type: Custom <br />
Thread account name: NT AUTHORITY\NETWORK SERVICE <br />
ViewStateException information: <br />
Exception message: Invalid viewstate. <br />
Client IP: 80.98.185.47 <br />
Port: 16528 <br />
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7 <br />
PersistedState: ML0cSytZ3NNxTv6HMBICK (… Here appears lines and lines of the viewstate dumped) … LecAy+p3fFVSdi7LZEE= <br />
Referer: http:
Path: ApplicationName/ApplicationForm.aspx aspx <br />
Custom event details: <br />
10/8/2006 6:01:15 PM ASP.NET 2.0.50727.0 <br />
Information Web Event 1316 N/A
Any help would be appreciated
Thanks
|
|
|
|