|
Hi all!
How can i reset the query string without redirecting but using postback?
From = ".../Main.aspx?Results=1"
To = ".../Main.aspx"
So when i click a button it does the above without redirecting it;
"response.redirect("Main.aspx")
Thanks in advance!
Regards,
Jensen
|
|
|
|
|
jensenx wrote: How can i reset the query string without redirecting but using postback?
Reseting querystring on postback is not possible. Why you want to do this
|
|
|
|
|
Hi Guys/Girls,
Have been beating my head against the wall over this one for a while, and have come to the conclusion that I have probably just overlooked something simple. I am happy to look at alternative methods to open the popup page, but would prefer to keep the existing method for the download of the file.
Here's the situation:
In the on-click event of a button I do some processing, then want to do two things (in no particular order)
1. Pop up a window that opens a page that displays a crystal report as a PDF (this page exists and works fine in its own right)
2. Download a file. (this function also works fine in its own right)
Here's the rub:
Currently, I use response.write to trigger the page popup like this:
Response.Write("<script language=javascript>window.open('pagename.aspx?ReportID=49&Param1=" & intParam1 & "','new_Win');</script>")
(I can't attach it to the link attributes as the param1 needs to be generated by the processing in the existing on click code.)
Then, I use functions that end up calling the following code to download the file:
<preprocessing happens here>
With Response
.AddHeader("Content-disposition", "attachment;filename=" & strFriendlyName)
.ContentType = "application/octet-stream"
.BinaryWrite(btFile)
.End()
End With
Naturally, with the code as it stands the system throws a hissy-fit as you can't use two responses for the one page (by design). Surely there is some way for me to open the crystal report/pdf viewing page in code without using the response.write or response.redirect, that will allow for the processing of the rest of the code (and hence the downloading of the file)???
As I said, I have probably missed something incredibly simple, and you ASP.NET gurus are going to go "silly bugger, why don't you just open the popup by using XYZ"... I am prepared to wear that!
Thanks in advance...
D.
-------------------------------------------
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Just bugger off and leave me alone!!
|
|
|
|
|
_Damian S_ wrote: but would prefer to keep the existing method for the download of the file.
You can't.
_Damian S_ wrote: Naturally, with the code as it stands the system throws a hissy-fit as you can't use two responses for the one page (by design).
That's correct.
_Damian S_ wrote: Surely there is some way for me to open the crystal report/pdf viewing page in code without using the response.write or response.redirect, that will allow for the processing of the rest of the code (and hence the downloading of the file)?
No. If you send the file to be downloaded in the response, there is no way of sending anything else what so ever in the response. Nothing. Nada. Zilch. Zip.
You have to make two separate requests to the server.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Guffa wrote: No. If you send the file to be downloaded in the response, there is no way of sending anything else what so ever in the response. Nothing. Nada. Zilch. Zip.
That's what I was afraid of...
Is there some way to trigger the popup form (other than using response.write) so that I can still use the response for the file download, or am I just going to have to redesign the process?
Thanks for taking the time to answer...
-------------------------------------------
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Just bugger off and leave me alone!!
|
|
|
|
|
You have to send two requests from the browser. You can either send both requests from the same page, or let the popup page send the request for the download.
It can't be done the other way, though. The request for the download is a dead end, and can only return the data for the download, it can't cause another request.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
No worries... Thanks again for your help.
I have resolved the issue by processing and producing the pdf on the first click, saving the ID to session state and then using a second click event to handle the creation of the file.
-------------------------------------------
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Just bugger off and leave me alone!!
|
|
|
|
|
I am trying to pass some parameters from one page to another. I have a project where if someone is a manager they can approve/deny certain requests. However, I am trying to display a message box alerting a user they cannot do certain functions. I created a simple example for her. I can click on a link on the first page that passes parameters in the URL. I grab the parameters. The problem is, it never displays the popup when I have response.redirect after it.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Response.Write(Request.QueryString["OrderBy"].ToString());
Response.Write("<br /><br />" + Request.QueryString["Page"].ToString());
Response.Write("<script language='javascript'>window.alert("+ '"' + Request.QueryString["OrderBy"].ToString() + '"' +");</script>");
Response.Redirect("Default.aspx");
}
}
|
|
|
|
|
Well, of course. Response.Redirect happens on the server, the page with the script is never sent to the client. You need to write this script into the default.aspx page, or pre populate the page so that on the client side, when the action is performed, the javascript runs prior to the postback.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello, i have a real time data problem,
Let me explain,
Im building a web site, in order to user acces to check the status of an application, ive already have the process to keep update the data, ive an arraylist, where I put the modified data , the a timer updates the data, so, I have a data table … a static data table, so what I do , I just modify the data, with the editrow( ) function, then I pass the object to a dataview so the paga can be repainted, so everything goes well to that point.
Why I have static table, ok, first cause my fuction is static.. so.. then cause I need that the data be the same for other users, so when I run the page on a server all the users see the same data on the table.
Ok the problem comes when each user initializes the page, cause, the initialize process “try” does the process of adding colums to the data table , colums that already exist, so a error message pop ups, telling me that it cant be created again, ok so… what im doing,
First I cant use a non static data table, cause each time a user enters the page, it wont have any data, … so, im trying to have a non static data table, then when I get a modification on the data I use this, (Im passing the structure from the non static data table to the static)
DataTable static StaticDatatable =new DataTable()
DataTable static NonStaticDatatable =new DataTable()
if (loadatfirst == 0)
{
DtMotor.Columns.Add(new DataColumn("Numero", typeof(string)));
DtMotor.Columns.Add(new DataColumn("Nombre", typeof(string)));
DtMotor.Columns.Add(new DataColumn("Estado", typeof(string)));
DtMotor.Columns.Add(new DataColumn("RPM", typeof(string)));
DtMotor.Columns.Add(new DataColumn("UniqDevice", typeof(string)));
loadatfirst = 1;
StaticDatatable = NonStaticDatatable ;
}
so, at this point it seems to be no problem, so I have a static function that adds information to the StaticDatatable
StaticDatarow = StaticDatatable.NewRow();
StaticDatarow [0] = numeromotor.ToString();
StaticDatarow [1] = d.FriendlyName;
StaticDatarow.Rows.Add(StaticDatatable);
The problem comes, after this… Im trying to pass the data to the non static table just even up the to tables with a simple
NonStaticDatatable = StaticDatatable;
So if a new user enters the page, the nonstatictable creates as a new object but when its going to repaint the info, pass the information to the static, so if its repeted it doesn’t add in the first place, so it supposed that the only data it would be the new and the old, but no repeted data,
But when a new users enter nothing happened, the data table is empty, and I don’t know why…
[code]
public static DataTable StMotor = new DataTable();
public static DataRow SrMotor;
public DataTable DtMotor = new DataTable();
public DataRow DrMotor;
public void generategrids()
{
MotorsGrid.DataSource = CreateDataMotor();
MotorsGrid.DataBind();
}
protected ICollection CreateDataMotor()
{
if (loadatfirst == 0)
{
DtMotor.Columns.Add(new DataColumn("Numero", typeof(string)));
DtMotor.Columns.Add(new DataColumn("Nombre", typeof(string)));
DtMotor.Columns.Add(new DataColumn("Estado", typeof(string)));
DtMotor.Columns.Add(new DataColumn("RPM", typeof(string)));
loadatfirst = 1;
StMotor = DtMotor;
}
/*
StMotor.Columns.Add(new DataColumn("Numero", typeof(string)));
StMotor.Columns.Add(new DataColumn("Nombre", typeof(string)));
StMotor.Columns.Add(new DataColumn("Estado", typeof(string)));
StMotor.Columns.Add(new DataColumn("RPM", typeof(string)));
StMotor.Columns.Add(new DataColumn("UniqDevice", typeof(string)));
* */
DataView dv = new DataView(DtMotor);
return dv;
}
private static void FuncMotor()
{
bool repetido= false;
for (int i = 0; i <= numeromotor-1; i++)
{
if ((string)d.UniqueDeviceName == (string)CpSMotor.MotorUnique[i])
{
repetido = true;
}
}
if (repetido == false)
{
numeromotor++;
SrMotor = StMotor.NewRow();
SrMotor[0] = numeromotor.ToString();
SrMotor[1] = “info”;
SrMotor[2] = “info”
SrMotor[3] = “info”; //test
SrMotor[4] = “info”;
StMotor.Rows.Add(SrMotor);
}
}
protected void refrescar_Click(Object sender, EventArgs e)
{
//DtMotor.Merge(StMotor, false);
DtMotor = StMotor;
for (int i = 0; i < DtMotor.Rows.Count; i++)
{
DtMotor.Rows[i].BeginEdit();
DtMotor.Rows[i][2] = “info2”
DtMotor.Rows[i][3] = “info2”
}
DataView dv = new DataView(DtMotor);
MotorsGrid.DataSource = dv;
MotorsGrid.DataBind();
}
[/code]
the issue is, I need the data form the code behind object, be the same for al the users, cause the page automaticlly request for new information throug a java timer, so when a modify data appears the code behind update on the data table, and pass it to the dataview in order to be repainted when the request comes.
|
|
|
|
|
Use the Cache on the first read to cache the data and then retrieve it from their there for your other users.
-- modified at 9:18 Thursday 25th October, 2007
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi
i am doing a project on online exam so that i want to keep timer control, but i could not find timer control in my ASP.NET 2005 toolbox. how can i get it. Please help me.....
should i import it from any where:?
:->
|
|
|
|
|
if you want to just give the user a set of time, let say a 5 min, to answer it, just search for a java timer, and add the action you want to , like go to another page, or show a message...
search it in google...
|
|
|
|
|
thq for ur reply...
Your idea is very good, but i want to use timer control in ASP.Net, i used timer control(just drag and drop from tool bar) in console base application in C#, but i could not find the same control in Asp.Net tool box.
|
|
|
|
|
joshi reddy podduturi wrote: but i want to use timer control in ASP.Net
There isn't one.
joshi reddy podduturi wrote: but i could not find the same control in Asp.Net tool box.
Because there isn't one.
You need to write a timer in javascript. You can use AJAX to send messages to the server from your timer, if you want to, as Mark said. But, you are going to have to write actual code. To be honest, it's beyond me why anyone would drag and drop a timer from the toolbox in any C# application, it's not a UI element, it's something you control in code. If you want to be a programmer, you need to be willng to write code.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
When the other answerer said java, he meant javascript. You can store DateTime.Now in the session and check it on postback to see how much time has elapsed, but any sort of timer that causes an action eeds to be written on the client side.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
It's not necessary for a complete postback, an ajax call could be made from the client to obtain the time and url, or action, to take upon expiration.
only two letters away from being an asset
|
|
|
|
|
That much is true, but this guy wants to drag and drop something, you want to complicate thngs with AJAX ? I suspect that writing a JS timer is scary enough for him.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
m sachin here..
now i m working into libraty management system.In this system i have use .net with C# and database connectivity with microsoft access.now if user wants to register then it should enter his id.And if some new student enter id which is already registered then it should give an error so how can we do that..
please send me code or method
MIRCHI IS VERY TIKHI
|
|
|
|
|
The best option will be to take uid as a uniqueidentifier in sqlserver.
and handle the sqlexcetion in try catch block..........
another way is use DataReader to read data with sqlcommand select * from tablenaem where uid='"+tbuid.Text+"'"
if(dr.Read())
{
Response.Write("already exist");
}
else its okay.............
try this it may be helpful 2 u..........
Deepak Nigam
|
|
|
|
|
hello dear!!!
i m studing in B.E IT in 7th sem.
i need some asp.net project to study porpose so plese send me if u have good project which can improve my knowlege
MIRCHI IS VERY TIKHI
|
|
|
|
|
malcolm smart here dear!
Why don't you write a libraty management system in which you have database connectivity with microsoft access and if user wants to register it should let him unless his id is registered before then tell him it is so that is what you can do. Dear.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Oh dear!
Cheers,
Mircea
"Pay people peanuts and you get monkeys" - David Ogilvy
|
|
|
|
|
Buy a book, or read the articles on this site. Seriously....
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I am developing ASP.Net application in VS2003. From when user login, I am maintaining one session variable.
Session["user"] = t1.text; some think like this. and making it null and abandon when logout is clicked.
Session["user"] = ""
Session.Abandon() ;
When I run my code on localhost I dont have any problem. every thing works perfectly. but when I deploy my application to main server then aumatically my session get expires , I mean session variable is becoming is null. This does not happen regularly. It happens after few transactions. Even unable to replicate when exactly this is happening. I kept timeout 20 minutes.Then also even while operating it expires.
I am already frustrated with this issue by chanding <sessionstate> in web.config and many replacements in my code. but no use.
Can any please guide me?
Thanks In Advance
|
|
|
|
|