Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
protected override void OnPreRender(EventArgs e)
  {
      base.OnPreRender(e); //what does this line do?
      string strDisAbleBackButton;
      strDisAbleBackButton = "<SCRIPT language=javascript>\n";
      strDisAbleBackButton += "window.history.forward(1);\n"; what this line do?
      strDisAbleBackButton += "\n</SCRIPT>";
      ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "clientScript", strDisAbleBackButton); // what does this line do?
  }


what this code do?
Posted
Updated 22-Jun-11 8:52am
v4

In the dim, dark past all documentation was printed on paper, and very heavy it was too. The first version of Visual Studio for example, (called Visual C++ in those days) had a single CD and pile of books you could stun an ox with. Still got them, somewhere. Oh, yes, I remember, they are in the Games Room. Never mind that.

The thing is, in those days, we had to find the right book, read the right section, and work out what functions did for ourselves. And very hard work it was too.

Nowadays, there is a tool called Google that does most of the work, and a set of books called MSDN which does the rest - and all searchable too. Amazing really.

Then you come along. "Can I be bothered to try to learn?" you think. "Nah. I'l just post stupid little questions asking what each individual line of code fragments I've raked up from the internet do instead." So you do. But I ain't answering.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Jun-11 15:16pm    
I fell next time you're going to write an assay in the Google use... :-) My 5.
--SA
Sergey Alexandrovich Kryukov 22-Jun-11 15:19pm    
By the way, did you check previous "questions" from OP? I thinks there are many reports of abuse. Why should anyone answer the question about code OP did not write? It cannot teach anything anyway.
--SA
OriginalGriff 22-Jun-11 15:21pm    
Yes - under about three names, I think. The OP does indeed seem to be learning resistant. :)
Sergey Alexandrovich Kryukov 22-Jun-11 18:30pm    
Three names?! In attempt to keep this activity even if one or two are suspended for this spam (because this is a kind of spam) I would guess. What's the use?..
--SA
OriginalGriff 23-Jun-11 4:04am    
Hope springs eternal in the human breast;
Man never Is, but always To be blest:
The soul, uneasy and confin'd from home,
Rests and expatiates in a life to come.

-Alexander Pope, An Essay on Man

Or something like that, anyway. :laugh:
This seems to be code from an ASP.NET custom control. The first line you queried about calls the base class' OnPreRender event. This is usually done to do stuff that the base class would already handle. The other line you asked about registers the script with the ASP.net script manager so the constructed javascript stored in strDisAbleBackButton is rendered to the HTML output.

Cheers!

--MRB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900