Transfer Value From One Page To Other?
Jan 10, 2011list out all the ways in which value can be passed from one way to another and a quick example for each.
server transfer
response redirect
sessions
cookies
list out all the ways in which value can be passed from one way to another and a quick example for each.
server transfer
response redirect
sessions
cookies
I have a class which implements IHttpHandler that is designed to handle image resize requests. It handles Urls like so [URL] Currently the handler looks for myimg.jpg on disk, cuts a 100x100 thumbnail (if it isn't already present) and redirects the client to the thumbnail like so Response.RedirectPermanent("/some/virtualPath/to/thumbnail.jpg");
This has been working great, but I would like to avoid forcing the client to issue a second HTTP request. Is it safe to do the following? Server.Transfer("/some/virtualPath/to/thumbnail.jpg") All the MSDN documentation talks about using Server.Transfer() to redirect to an aspx page, so I'm not sure if this is the right thing to do or not.
I need to pass api key in custom http header ('X-ApiKey') and pass to another page. The second page will read that api key and do further processing. If api key is not passed in, it will redirect to error page.
I tried this way, but it didn't work.
In First.aspx page
Response.AppedHeader("X-ApiKey", "xxxxxxxxxx");
Response.Redirect("Second.aspx");
In Second.aspx page
string apikey = Request.Headers.Get("X-apiKey");
but X-apiKey is not passed in in second.aspx http header and ended up redirecting to error page.
How we transfer my session from http page to https page.
View 3 Replieshow do I transfer my data to another page.
Have 3 textbox whose value must be transferred..
In the course I'm taking they taught me to use Response.Redirect like this:
Response.Redirect(string.Format("name.aspx?sb="+bts+"&del="+delimiter));
Is there a better way to do so?
Sometimes when transferring to a different page, I have to use response.redirect instead of server.transfer, and when I do, the name of the page always shows up in the url such as [URL]
I use server.transfer when I can, but unfortunately I haven't found a way to use it unless the transferred page refers back to the parent when leaving.
How can I mask what page is being viewed after doing a response.redirect to another page.
To get the url of the current page, I usually do something like this:string path = Request.Path;If I do this after a Server.Transfer then I get the path of the page where the transfer was done. How can I get it for the current page?For example:
On Page1.aspx I do Server.Transfer ("Page2.aspx")
On Page2.aspx Request.Path returns /Page1.aspx and not /Page2.aspx
What's wrong with this code?
Source page : Default.aspx
[Code]...
as u know, you can call Server.Transfer() or place some values in Session["objName"]=value; inside your page. but i'm writing a class which has not page, so it does not have any Server or Session object.
how can call this objects or methods outside of the page (within my class) ?
i have a problem to transfer data from first page to another page...
basicly my web site that i build now have like 4 pages..so i name it registration1 - registration4 ...
the problem i face now is when user click to next page button..so the data entered on that page cannot retrieve from another page...for example..
firstpage ;
-User enter data on the form that i design for registration...and then click send..
second page:
-user enter another data on the other form again...and click send
third page:
-user enter another data on the other form again...and click send
forth page:
-all the information give to user from first page to 3rd page will display..and have a button to print all the information..
my problem is i cant retrieve data from every single page...
how to transfer the grid view from one page to another.
i insert data in one page , i need grid view should display in next page.
I have used a image handler to display image which works fine... My problem is how can v pass the image using sessions on different pages. I have an image control in master page and fileupload control on the content page.... bt m not able to implement sessions for images as image can't be store to string.
View 1 RepliesI wanTransfer values from one page to another using Request Object
but when i try store
textBox value into Request object like..
Request["Name"] = txtName.Text;
i get the following Error
Property or indexer 'System.Web.HttpRequest.this[string]' cannot be assigned to -- it is read only
Is Request object allows us to store values init like Session & Application Object.
How would I transfer the values of an array created at runtime from one page to another? I tried using Response.Redirect because single values are getting transferred, but this isn't working properly with the array.
View 1 RepliesI am new at this VB/Microsoft Visual Web Developer 2010 Express thing. I am amaze that I even got this far and thatI manages to make this search page work. Below is the code and picture for this search page. It's working. However I want to transfer the result/the gridview onto a second page Result.aspx. But I tries all kind of thing and it just doesn't seem to want to cooperate with me. If anyone can give me some hint/some sample codes on how I might be able to transfer controlfrom one page onto another. I just have to learn it from a class extra credit project. Also in the picture above I am using a direct connection to an Access database not the ObjectDataSource. I was just playing around with it to see which is better. But I ended up going with direct connection to Access database.
<%@ Page Language="VB" ClassName="SenderClass" EnableSessionState="True" %>
<head>
<script runat="server">
Sub closeSite(ByVal sender As Object, ByVal e As EventArgs)
Response.Write(" <script language='javascript'> { window.close(); }")
End Sub
Sub Page_Transfer(ByVal sender As Object, ByVal e As EventArgs)
'Storing in Context
Session("SearchBox") = SearchBox.Text
Session("ListBox") = ListBox1.Text
Session("DropDownList") = DropDownList.DataTextFormatString
'Context.Items("DropDownList") = DropDownList.Text
'Server.Transfer("SearchResult.aspx")
End Sub
Sub Page_Transfer2(ByVal sender As Object, ByVal e As EventArgs)
Dim field1 As String = ("SearchBox")
Dim field2 As String = ("ListBox")
Dim field3 As String = ("DropDownList")
'Dim TestString As String = ("SELECT * FROM [Books] WHERE (([Title] = ?) AND ([Category] = ?))")
End Sub
Sub Test(ByVal sender As Object, ByVal e As EventArgs)
AccessDataSource1.SelectCommand = "SELECT * FROM BOOKS WHERE "
If DropDownList.SelectedIndex = 0 Then
AccessDataSource1.SelectCommand += String.Format(" ((Category = @Category OR 'Computer' ")
AccessDataSource1.SelectCommand += String.Format(" OR 'Literature & Fiction' OR 'Reference'")
AccessDataSource1.SelectCommand += String.Format(" OR 'Romance' OR 'Science'")
AccessDataSource1.SelectCommand += String.Format(" OR 'Home Design' OR 'Accounting & Finance'")
AccessDataSource1.SelectCommand += String.Format(" OR 'Horror' OR 'Refernce'))")
Else
AccessDataSource1.SelectCommand += String.Format("(( Category = @Category ))")
End If
For Each Item As ListItem In ListBox1.Items
If Item.Selected = 0 Then
AccessDataSource1.SelectCommand += String.Format(" AND ((Title Like @Search + '%'", Item.Text)
AccessDataSource1.SelectCommand += String.Format(" OR [Author(s)] Like @Search + '%'", Item.Text)
AccessDataSource1.SelectCommand += String.Format(" OR Publisher Like @Search + '%'", Item.Text)
AccessDataSource1.SelectCommand += String.Format(" OR ISBN Like @Search + '%'", Item.Text)
AccessDataSource1.SelectCommand += String.Format(" OR Price Like @Search + '%'", Item.Text)
AccessDataSource1.SelectCommand += String.Format(" OR Category Like @Search + '%'", Item.Text)
AccessDataSource1.SelectCommand += String.Format(" OR Year Like @Search + '%' ))", Item.Text)
End If
If Item.Selected = 1 Then
AccessDataSource1.SelectCommand += String.Format(" AND (Title Like @Search + '%' )", Item.Text)
End If
If Item.Selected = 2 Then
AccessDataSource1.SelectCommand += String.Format(" AND ([Author(s)] Like @Search + '%' )", Item.Text)
End If
If Item.Selected = 3 Then
AccessDataSource1.SelectCommand += String.Format(" AND (Publisher Like @Search + '%' )", Item.Text)
End If
If Item.Selected = 4 Then
AccessDataSource1.SelectCommand += String.Format(" AND (ISBN Like @Search + '%' )", Item.Text)
End If
If Item.Selected = 5 Then
AccessDataSource1.SelectCommand += String.Format(" AND (Price Like @Search + '%' )", Item.Text)
End If
If Item.Selected = 6 Then
AccessDataSource1.SelectCommand += String.Format(" AND (Category Like @Search + '%' )", Item.Text)
End If
If Item.Selected = 7 Then
AccessDataSource1.SelectCommand += String.Format(" AND (Year Like @Search + '%' )", Item.Text)
End If
Next
Dim KeywordCom As String = AccessDataSource1.SelectCommand.ToString
Context.Items("Test") = KeywordCom.ToString
Server.Transfer("Result.aspx")
End Sub
</script>
</head>
<html>
<body>
<a href="Default.aspx">Home</a>
<a href="About.aspx">About.aspx</a><a href="SearchResult.aspx">SearchResult.aspx</a>
<form id="form1" runat="server">
<h3>
Search for:
<asp:TextBox ID="SearchBox" runat="server" Width="219px" />
<asp:Button ID="Button1" Text="Search" Width="146px" AccessKey="S"
runat="server" Enabled="True" Onclick="Test" height="26px"
style="position: relative"/>
</h3>
<h3>
Search In:<asp:ListBox ID="ListBox1" runat="server" style="margin-left: 6px"
Width="221px">
<asp:ListItem>Keyword Anywhere</asp:ListItem>
<asp:ListItem>Title</asp:ListItem>
<asp:ListItem>Author(s)</asp:ListItem>
<asp:ListItem>Publisher</asp:ListItem>
<asp:ListItem>ISBN</asp:ListItem>
<asp:ListItem>Price</asp:ListItem>
<asp:ListItem>Category</asp:ListItem>
<asp:ListItem>Year</asp:ListItem>
</asp:ListBox>
</h3>
<h3>
Category:
<asp:DropDownList ID="DropDownList" runat="server" Height="16px" Width="162px">
<asp:ListItem>All Categories</asp:ListItem>
<asp:ListItem>Computer</asp:ListItem>
<asp:ListItem>Literature & Fiction</asp:ListItem>
<asp:ListItem>Reference</asp:ListItem>
<asp:ListItem>Romance</asp:ListItem>
<asp:ListItem>Science</asp:ListItem>
<asp:ListItem>Home Design</asp:ListItem>
<asp:ListItem>Accounting & Finance</asp:ListItem>
<asp:ListItem>Horror</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button3" runat="server" Text="Exit Store" Width="146px"
height="26px" />
</h3>
<p>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource1" >
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="ISBN" HeaderText="ISBN" SortExpression="ISBN" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Author(s)" HeaderText="Author(s)"
SortExpression="Author(s)" />
<asp:BoundField DataField="Publisher" HeaderText="Publisher"
SortExpression="Publisher" />
<asp:BoundField DataField="Year" HeaderText="Year" SortExpression="Year" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="Category" HeaderText="Category"
SortExpression="Category" />
<asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="Select"
ShowHeader="True" Text="Select" runat="server" />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/Books.accdb" >
<SelectParameters>
<asp:ControlParameter Name="Category" ControlID="DropDownList" PropertyName="SelectedValue" />
<asp:ControlParameter Name="Search" ControlID="SearchBox" PropertyName="Text" />
<asp:ControlParameter Name="InColumn" ControlID="ListBox1" PropertyName="SelectedValue" />
</SelectParameters>
</asp:AccessDataSource>
</p>
<p>
</p>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
i am developing a login page.After matching there given and actual credentials i have to show there own private page.So which method should i use now.Which is better one ?Server.Transfer of Response.Redirect ?How can i access login page's data in the user's home page if i use Server.Transer method without using Session variable ?
View 2 RepliesI want to transfer a variable to another page when a button is clicked. I include the html code in label.text.
Source code is as follows:
MyLabel.Text += "<button type="button" onclick="location.href='a.aspx?oid='+this.oid"><b>Detail</b></button>";
oid is the variable that I want to transfer.However, It says "http://localhost:61884 OBJ_Browser.aspx?oid=undefined" when I click this button.
how I can transfer the value of oid to another page?
I want to pass my textbox value to another page and display in label on submit button click on first page...
View 1 Repliesi am creating a print view using checkboxes that a customer uses to select which items they wish to print. I am having difficulty transfering the selected gridview items to another page. I was using crosspage post.
View 2 RepliesWhat is the easy/safe way to get all HttpContext.Current data (like querystring, etc) in the previous page, after response.redirect or server.transfer to another page?
I am using .net 3.5
I have a very simple application. You have a master page. Within the CS of the master page you do a Server.Transfer to another page that inherites the master page. As a result you get an infinite loop. The problem is that I can't check with if statements to prevent the loop.
View 2 RepliesIn my gridview I got 7 colunms, the first is a checkbox colunm. When the user clicks the "From" colunms data IE "who the message is from" two need to happen. One the application navigates to the next URL and the user can read his/her mail, two and here my issue how do I transfer the data from each colunm to the next page...I was thinking session some how?
View 1 RepliesI built a data list list in the follow. It seems that href is not asp language. How can I transfer it to asp language?
<ItemTemplate>
<a
href="~/Team.aspx?Id=<%#Eval("TeamId")%>">
<%#Eval("TeamName") %>
</a>
</ItemTemplate>
how to transfer data from one page gridview to another page gridview
in my gridview control 1st column is checkbox,2nd column is product name, 3rd column is price, 4th column is quantity
5th column is total. in this gridview iam using paging, when user selects any no of checkbox that selected row data i have to take it to another page
but iam facing problem when iam selecting some records from 1st page and then iam visiting next page then previous page records iam missing.