|
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
|
|
|
|
|
|
Do not ever ask for the code on CodeProject. You will be treated like this ^
|
|
|
|
|
arun$aini wrote: You will be treated like this
Deservedly so.
me, me, me
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
This code to find the MAC address of a PC connected to the internet.
What's a sName in the code?
public class GetMacAddressFromIPAddress
{
[DllImport("iphlpapi.dll", ExactSpelling=true)]
public static extern int SendARP( int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen );
public string GetMacAddress(string sName)
{
string s = string.Empty ;
System.Net.IPHostEntry Tempaddr = null;
Tempaddr = (System.Net.IPHostEntry)Dns.GetHostByName(sName);
System.Net.IPAddress[] TempAd = Tempaddr.AddressList;
string[] Ipaddr = new string[3];
foreach(IPAddress TempA in TempAd)
{
Ipaddr[1] = TempA.ToString();
byte[] ab = new byte[6];
int len = ab.Length;
int r = SendARP( (int) TempA.Address, 0, ab, ref len );
string sMAC = BitConverter.ToString( ab, 0, 6 );
Ipaddr[2] = sMAC;
s = sMAC;
}
return s;
}
}
modified on Tuesday, May 25, 2010 4:01 AM
|
|
|
|
|
sName is IPAddress
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
And this case , it's the internet ip address and not the pc ip address, isn't it?
2nd thing is that, when using this code, how to suppply internet address for it, do I have to get a code to detect the internet ip address and then pass it to the MAC Function?
THanks
|
|
|
|
|
Hi,
Is it that IIS spawn a seperate worker process for all FTP requests, one for all HTTP requests, one for other
message based requests
or is it that there is only one worker process in totality and there can be any number of application domains no matter
whether the request is FTP, HTTP or any message based requests
Thanks,
NetQuestions
|
|
|
|
|