|
You have to release resources used during the first phase of your code, which is saving file into physical space/directory. For example:
fileObjectUsed.dispose();
OR
FileUpload1.dispose();
I would recommend you not to store file into your web server location as this will add extra overhead of saving and deleting files and of-course security problem. You can directly store it(file) into database by converting it to bytes. Check out the link Storing Binary Data to Database using ASP.NET 2.0[^]
Observe the code lines...
Dim imageBytes(fileUpload1.PostedFile.InputStream.Length) As Byte
fileUpload1.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length)
puranonnet@hotmail.com
BCS Technology
|
|
|
|
|
Lots of information missing though. The moment you uploaded it to temp folder, how do you upload it to database? Is the upload to DB process simultaneously going on? Immediately or afterwards? Is that process of uploading to DB is in progress when you try to delete it?
Looks like the temporary folder is a Sourcesafe folder. Those are write protected.
Lastly, you should directly upload it to DB instead of inserting an extra step in between and having a performance hit!
|
|
|
|
|
i m using UrlRewritingNet and url rewriting is working fine but i m facing a serious issue. i have just one page in the site. and lots of updatepanel are used in the sites. i have use the rules as u define in ur article.
<urlrewritingnet
rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString"
defaultPage = "default.aspx"
defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >
<rewrites>
<add name="Detail"
virtualUrl="^~/detail/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/detail.aspx?s=$1"
redirect="none"
ignoreCase="true"
/>
</rewrites>
</urlrewritingnet>
i have check when the paging is clicked the response is sent to the server but the pagebutton click event is not fireing.
and as a result i get this error.
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '
<!DOCTYPE html P'.
i hope u will have solve this problem.
i think its .axd problem please sugest a solution.
amirzada
|
|
|
|
|
It looks like you want to ask this question to an author related to his/her article.
I would suggest you to please use the forum present at the end of the article in order to reach author and get quick response. Rarely you will find authors reading this forum.
Please post the same at the article's message forum.
|
|
|
|
|
hi,
i am having a page with gridview and i want to open the page in master page...so to do this i removed the runat server attribute from the page and on the link button of the master page i referred the page with gridview ...but showed me an error " form with gridview must have runat=server attribute". when i put this attribute...and try to open in master page, the page with gridview loads leaving the masterpage....i figured out that when my masterpage form and gridview page form tag both have runat= server attribute then the gridview page will be loaded leaving the masterpage.
Afiz Momin
|
|
|
|
|
please, tell me if u need a code .
|
|
|
|
|
What is this? Why are you posting to your question. In case you want to add anything to whatever you have asked, you can always go and edit it!
|
|
|
|
|
Ok! Here are few things you need to read on first...
1. What does runat=server means. So, basically, what will happen if you remove it or add it to the control.
2. Can a page that has a Master page have multiple form tags that has 'runat=server ' in it? How many form tags with runat=server is allowed?
|
|
|
|
|
runat=server attribute indicates that the element should be treated as a server control And page can have one or more forms in page.
How many form tags with runat=server is allowed? --> this thing i dont know.
but form requires a runat attributes when using GridView
Plz give briefing on this and solution to the problem..
thank u..
|
|
|
|
|
|
hello all,
I have made a project like OnlineExam.
In this, I want to restrict the Back button of the client browser so that after submitting the test, it should redirect last page or you can say results page. And if user clicks on the back button, it should not redirect to the Questions page again,
plz help
Thanks in advance.
|
|
|
|
|
Although, there are lots of hacks using javascript to disallow navigating back, but those are, as per my belief, not all foolproof. I would suggest you to use Cache.SetNoStore() on the page where you don't want to allow user to visit using back button. Back button actually presents the page using stored cache on browser client.
Here is the code which you can place in page load event...
Response.Cache.SetNoStore();
This will make each and every visit to this page to be fetched from server. You can add some code logic or session variable etc to check if it is a valid page request.
I hope this will help.
puranonnet@hotmail.com
BCS Technology
|
|
|
|
|
no friend..its not working ....i have already used it......
|
|
|
|
|
You need two session variables. ExamStarted and ExamFinished. Set the ExamStarted variable when they start the exam. When they submit the test set the ExamFinished variable. Then in every question page check for the ExamFinished session variable. If it is set then redirect.
|
|
|
|
|
You can disable the Browser back button such that the scenario does not occur:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
You can add something similar in form aspx if you want to place it there:
<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">
OR
<SCRIPT LANGUAGE=javascript> { var Backlen=history.length; history.go(-Backlen); window.location.href=page url }</SCRIPT>
OR
Page.ClientScript.RegisterStartupScript(this.GetType(),"cle","windows.history.clear",true);
OR as you say in you logout event:
protected void LogOut()
{
Session.Abandon();
string nextpage = "Logoutt.aspx";
Response.Write("<script language=javascript>");
Response.Write("{");
Response.Write(" var Backlen=history.length;");
Response.Write(" history.go(-Backlen);");
Response.Write(" window.location.href='" + nextpage + "'; ");
Response.Write("}");
Response.Write("</script>");
}
|
|
|
|
|
I would approach it differently.
I would create multiple ascx files if you want different "pages" and step through these .ascx files by postback.
This makes the system far more extensible because if you want to add new questions, or add questions dynamically, all you have to do create another .ascx file and reference it in the .aspx page. Or, you could reate one .ascx file and load the questions dynamically from a database or XML file, and just use postback to keep track of each question. Keep track of the current question with a session state, but then the "back" and "forward" buttons become irrelevant because you are displaying whatever .ascx file you've selected in postback.
Ryan
|
|
|
|
|
I have used simple web page for the questions to be displayed. After submitting the questions, user redirects to another page i.e. thanks.aspx and in that page, I have used the session.removeAll() in the PageLoad event.
Now I want that when user clicks on the back button of his browser from that page(i.e thanks.aspx), Questions.aspx page should not display the same questions again. Instead, that page must be empty.
I hope u get my point..
thanks anyways
|
|
|
|
|
That's even easier to fix.
From what I understand you basically have two pages:
test.aspx and thankyou.aspx . Test.aspx as all of your questions and thank has all of your processing code. Test.aspx redirects to thankyou.aspx .
If this is the case, here is what I would do:
On any page before you go to test.aspx (I'm sure you have a page like (testinstructions.aspx), create a session:
Session[TEST_FINISHED] = false;
Then check the test page for the session:
bool bTestComplete = (bool)Session[TEST_FINISHED];
if (bTestComplete == true)
{
Response.Redirect(thankyou.aspx);
}
Finally, set a session on thankyou.aspx like this:
Session[TEST_FINISHED] = true;
So when the user lands on the test page, the TEST_FINISHED session is set to true. This will insure that the user is never able to go back to the test page.
Is that what you are looking for?
Ryan McBeth
|
|
|
|
|
yes ....I wanted to have like that and I have used that code in my project but every time, after clicking on the submit button of the test.aspx page & it redirects to the thanks.aspx, When user clicks on the back button,again it redirects to the test.aspx webpage and in that page,questions are displayed in the same way......
could you give me alternative of using sessions in my project ???
And thanks for the answer
|
|
|
|
|
It may be tough to do unless you use session states because you have to record the state of the user.
If you put the Response.redirect("thanks.aspx") in the page_load method along with the if Statement, it should work by kicking the user out.
But there is always another way. Let me think about it.
Ryan McBeth
|
|
|
|
|
Ok, brother I'm still on the case.
I can think of one more option if sessions are out of the question.
Create a third page called process.aspx . <ake the="" page_load="" method="" do="" same="" thing="" thank_you="" page="" did,="" but="" add="" an="" immediate="" redirect="" to="" thankyou.aspx
so="" business="" process="" would="" look="" like="" this:
test.aspx="" -=""> process.aspx -> thankyou.aspx
If the user hits the back button, they go immediately to process.aspx and get redirected back to thankyou.aspx . Now, this won't help if the user holds down the "back" key and chooses test.aspx, but it may work in 90% of your cases, and if you are having trouble with setting sessions, that may be good enough.
If that won't work, post your page_load method for test.aspx and thankyou.aspx and I'll take a look at it.
Ryan
|
|
|
|
|
alright...I'll try this..will get back to you.
thanks
|
|
|
|
|
hi Ryan..
I have implemented the idea of including the third page(say process.aspx) between the test.aspx and thanks.aspx.But,the Third page inclusion does help somewhat but what if user clicks browser's back button subsequently after submitting the test....?
By doing this, user redirects to the first page again, and between these subsequent clicks, the pages showing the same data again and again..
|
|
|
|
|
Okay,
Maybe I'm not understanding the whole scope of the problem. If you set a session on the test page and check for that session in the page_load and force a redirect if the test has been submitted, any subsequent return to that page should force the user back to the "thankyou.aspx" page. This is especially frustrating because I work for a company that writes online personality tests. So here's what I do in a nutshell with very, very simplified business logic:
notification.aspx -> answerSheet.aspx -> thankyou.aspx
What I really do is keep it all on the same page and use AJAX and custom controls, but that doesn't help you with your problem.
So here is the rundown (forgive me if there are syntax mistakes here, I'm doing this quick before a meeting):
notification.aspx - This page explains the test, sets up some user info and sets the following in page_load.
protected void Page_Load(object sender, System.EventArgs e)
{
Session[COMPLETE] = false;
}
answerSheet.aspx - This page has the radio buttons for answers. It's here that I would have the following code inside the Page_Load() method in the answersheet.aspx codebehind file:
protected void Page_Load(object sender, System.EventArgs e)
{
if (Session[COMPLETE] == null)
{
Response.Redirect("notification.aspx");
}
if (Session[COMPLETE] == true)
{
Response.Redirect("answerSheet.aspx");
}
}
thankyou.aspx - This page would have the following code:
protected void Page_Load(object sender, System.EventArgs e)
{
Session[COMPLETE] == true;
}
The following code will allow the user to go back to the answer sheet, but it won't matter because on page load, they will be redirected back to the thank you page.
I will not give up on you, brother. If this doesn't help, post the code in the page_load methods and we can go from there.
Ryan McBeth
|
|
|
|
|
thanks for your concern Ryan.
But i have implemented another alternative for this. I have used onLoad event in the thanks.aspx in its body section as following:
.......................
.............
by doing this,the back button after reaching at thanks.aspx webpage, is disabled. It means it doesn't redirect to the test.aspx webpage again and again.
but I'll use the code you have sent this time and let you know it helps.
And if it doesn't work, then i'll give you the code of those webpages.
Thanks
|
|
|
|