Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. jesh

    URGENT : REGEXP

    Hmm, I can help a little, but I can't tell you exactly what that regular expression does.The pipe character - | - is for ORs and the parentheses define groups.The first group - (^|\\t|,) - would appear to make it so that the string is only matched if it either is at the beginning of the line (^), starts with an escaped tab character (\t), or a comma. The double backslash - \\ - is used to match a single backslash, so \\t would match "\t" rather than an actual tab character.The second group - (\"*|'*) - matches an asterisk preceded by a double or single quote. "* or '* would be matched.The third group - (.*?) - matches a dot (.) zero or more times. Don't ask me to define the difference between a "Greedy" and "Lazy" lookup. All I know is that this one is "Lazy".The next part - \\2 - I can't quite explain. The only thing I can think of is that it is trying to match a backslash followed by a 2 - "\2". If it were "\2" rather than "\\2", it might be used for a substitution.The last group - (?=,|\\t|$). This is a look-ahead. This looks ahead in the string and only returns a match if whatever preceded it ends in a comma, a \t (again, not a tab character, but a backslash followed by a t), or the end of the string ($).Finally, it appears that the s.replace(pattern, "$3\t") will replace a dot (or series of dots) with a tab character when a match is found. $3 refers to the third group - (.*?).That's about all the help I can offer. Check out this site for more info:http://www.regular-expressions.info/
  2. OMG, I found a solution here!This is what I had to add to my BeginRequest event handler. Now I just need to understand what's going on! heh. I'll look into it later, I suppose.Here's the code: protected void Application_BeginRequest(Object sender, EventArgs e){ int maxRequestLength = 1048576; // 1MB if (Request.ContentLength > maxRequestLength) { HttpApplication app = sender as HttpApplication; HttpContext context = app.Context; HttpWorkerRequest wr = (HttpWorkerRequest)(context.GetType().GetProperty("WorkerRequest", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(context, null)); byte[] buffer; if (wr.HasEntityBody()) { int contentlen = Convert.ToInt32(wr.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentLength)); buffer = wr.GetPreloadedEntityBody(); int received = buffer.Length; int totalrecv = received; if (!wr.IsEntireEntityBodyIsPreloaded()) { buffer = new byte[65535]; while (contentlen - totalrecv >= received) { received = wr.ReadEntityBody(buffer, buffer.Length); totalrecv += received; } received = wr.ReadEntityBody(buffer, contentlen - totalrecv); } } context.Response.Redirect("~/Error.aspx"); }}
  3. Well, I just ran a test. My maxRequestLength is set to 4096 (4MB). In my Global.asax file, I have the following:protected void Application_BeginRequest(object sender, EventArgs e){ Server.Transfer("Error.aspx");} This, as would be expected, sends all requests to "Error.aspx". Not very usefull, to be sure, but it does prove that you can transfer the request to the Error page from within this event handler.However, when I change the code to: protected void Application_BeginRequest(object sender, EventArgs e){ if(Request.ContentLength > 0) { Server.Transfer("Error.aspx"); }} It breaks. Simply visiting any page transfers the user to "Error.aspx" as before, but as soon as you post a request with a content-length > 0 (i.e. upload a file of 10KB, 100KB, 1MB, etc), the Application_BeginRequest event handler fires twice and I get that "Connection was reset" error in Firefox. Any ideas? Have you seen anything like this before? ASP.NET 2.0, IIS 5.1
  4. Yeah, I'm starting to see that as my only option. I've found other articles on the Internet that say that I should be able to do something like this in the Page_Error event handler: protected void Page_Error(object sender, EventArgs e){ string message = Server.GetLastError().Message; Server.ClearError(); Response.Redirect("~/Error.aspx?error=" + message);} I've placed breakpoints on each step there and the code seems to execute properly (i.e. Server.GetLastError() returns null after calling Server.ClearError()) but the page never redirects. Furthermore, this event fires twice when I upload a file which is too large (and the Application_BeginRequest event fires twice as well). Any idea why I'd be getting two requests?
  5. jesh

    Time Display Prob

    Try this instead: var time = new Date();time.setDate(time.getDate() + 15); Here is the whole script: <script language="JavaScript1.2"><!-- Beginvar months=new Array(13);months[1]="January";months[2]="February";months[3]="March";months[4]="April";months[5]="May";months[6]="June";months[7]="July";months[8]="August";months[9]="September";months[10]="October";months[11]="November";months[12]="December";var time=new Date();time.setDate(time.getDate() + 15);var lmonth=months[time.getMonth() + 1];var date=time.getDate();var year=time.getYear();if (year < 2000) // Y2K Fix, Isaac Powellyear = year + 1900; // http://onyx.idbsu.edu/~ipowelldocument.write("" + lmonth + " ");document.write(date +", " + year + "");// End --></script>
  6. jesh

    Installing a Database

    What if you created the .mdb file with all the appropriate tables and then simply made copies of it for the new users?Using the System.IO.File class, it could look something like this: string path = Server.MapPath("whatever/the/path/is/"); string originalFile = path + "template.mdb"; string newFile = path + "newfile.mdb"; if(System.IO.File.Exists(originalFile)) { System.IO.File.Copy(originalFile, newFile); }
  7. I can place the upload code in a try/catch block. The problem that I'm encountering, however, is that IIS is flat out rejecting the request before it even gets through to the page. So the upload code never executes - the request isn't making it to the page.The person submits the form, it gets posted back to my page, and then, before the OnInit event fires, IIS rejects the request because of the maxRequestLength.I'm starting to think this is an impossibility.
  8. The problem is that IIS rejects the request before the OnLoad event on the page gets any chance of running. This means that I can't add any error handling in the page.I've tried both the Application_Load and Page_Load event handlers, and I can get at the Exception, but IIS won't allow me to use a Server.Transfer() or a Response.Redirect(). And no matter what I put in the Web.config for customErrors, it's all ignored.Doesn't work: protected void Page_Error(object sender, EventArgs e){ Exception exception = Server.GetLastError(); if (exception is HttpException) { Server.ClearError(); Response.Redirect("Error.aspx"); // Server.Transfer("Error.aspx"); // Code executes up to this point, but the page still loads the // "The connection was reset" in Firefox and "Cannot find server or DNS Error" // in IE. }} Neither does this: protected void Application_Error(object sender, EventArgs e){ Exception exception = Server.GetLastError(); if (exception is HttpUnhandledException) { if (exception is HttpException) { Server.ClearError(); Response.Redirect("Error.aspx"); } }} Neither does this in the Web.config: <customErrors mode="On" defaultRedirect="Error.aspx"> <error statusCode="403" redirect="Error.aspx"> <error statusCode="404" redirect="Error.aspx"> <error statusCode="500" redirect="Error.aspx"></customErrors> And I can't use the FileInfo class because 1) the file resides on the client computer and 2) the request never gets to complete.I'm starting to investigate whether I can hijack the request in the Application_BeforeRequest event handler and stop it before the exception is thrown.
  9. I have a file upload control on one of my pages which works flawlessly - as long as the user doesn't attempt to upload a file larger than .NET's default maxRequestLength of 4096 KB.I don't want to change the maxRequestLength (if anything, I might make it smaller), but I want to handle this error in a graceful way rather than spitting out the awful "Cannot connect to server" error.I understand that I can add some global error handling in with the Application_Error event handler in the Global class, but I was wondering if anyone here has experienced this and used some other means of handling this error?I can do: protected void Application_Error(object sender, EventArgs e){ Exception exception = Server.GetLastError(); HttpUnhandledException uhex = (exception as HttpUnhandledException) if(uhex != null) { // do my error processing here... }} But does anyone know if there are any page-level methods I could employ?
  10. Rather than a two-dimensional array which holds the text and value of an option, you might consider two one-dimensional arrays - one for texts, one for values - or a single one-dimensional array which holds the options themselves: var myOptions = new Array();var option = document.createElement("option");option.text = "Option One";option.value = 1;myOptions[myOptions.length-1] = option; This might alleviate some of the complexity of having a two-dimensional array. Then, if you wanted to add the options to the select, you could do this: var mySelect = document.getElementById("mySelectId");for(var i = 0; i < myOptions.length; i++){ mySelect.add(myOptions[i]);}
  11. So now you need to get that getPage() function to run? You said <body onload="java script:getPage();"> didn't work, have you tried this?: <body onload="getPage('');"> You might also, for debugging purposes, add the following to your getPage function: var file = 'read.php?page=Hendrick';xmlhttp.open('GET', file + page, true);xmlhttp.onreadystatechange=function() { alert("readyState = " + xmlhttp.readyState); // <--- add this for debugging if (xmlhttp.readyState==4) { alert("status = " + xmlttp.status); // <-- add this for debugging if(xmlhttp.status == 200) // <--- add this for good practice { var content = xmlhttp.responseText; alert("content = ]" + content + "["); // <--- add this for debugging if( content ) { document.getElementById('content').innerHTML = content; } } }}xmlhttp.send(''); // <-- send('') rather than send(null) So, the alerts should pop up if there wasn't any problems with creating the xmlhttp object and sending off the request. If you see the alert which says "status = 200" then you know that the request was sent and the response came back ok. The next alert should show you the content. If you see "content = ][" then the response came back null and there is something going on with your PHP page. Hope this helps.
  12. But it still appears that you are passing a "page" parameter through your "getPage" function and then appending that value to your "file" variable so the request that you are sending through AJAX will look something like this:"read.php?page=Hendrick" + page Is that what you are hoping for? If so, what is the value that you are passing as "page"?Additionally, what happens if you simply type "read.php?page=Hendrick" into your address bar? Does that PHP file load correctly?
  13. As soon I as walked away from my computer I realized that the HTML DOM isn't really going to do anything for you since you'll be taking care of all of this from the server side. You'll want to follow this tutorial to get at the form values: http://www.w3schools.com/asp/asp_inputforms.asp
  14. This page should explain how to send an email with ASP: http://www.w3schools.com/asp/asp_send_email.asp.Since you know HTML, CSS, and Javascript, you should be able to look over the HTML DOM tutorial to get a feeling for how you can get the values of your form and use that data to build your email.
  15. At this point in your code: var file = 'read.php?user=Hendrick';xmlhttp.open('GET', file + page, true); What is the value of "page"? More specifically, what is the value of "file + page" and what happens when you attempt to visit that URL by typing it into your address bar? Are you missing an & after "user=Hendrick"?
  16. jesh

    AJAX Forum

    I would like to say that it behaves oddly, but I probably think that it behaves oddly because I'm unfamiliar with it. I just kept getting no response when I tried it in IE where responseText worked fine. I've recently read that the response type for the data needs to be "text/xml" in order for responseXML to work, maybe that was the issue I had. I haven't gone back to try the XML version so I might not find it difficult to work with any more.
  17. You might try going back to the .remove(i): http://www.w3schools.com/htmldom/met_select_remove.aspprocess.options = null probably works, it just might not work how you expect it to.
  18. YEA! It is the name of the window. You could name your popup window whatever you want, I just chose "_swfs" because you happened to be using it to open your swf files. You could name it "MyWindowFromPDX" if you wanted.Then it'd look like: open_win('','MyWindowFromPDX',390,720);The target is telling the browser where to open the URL. Since we named the window "_swfs" (or "MyWindowFromPDX") then we specify target="_swfs" (or target="MyWindowFromPDX").Does that clear it up?
  19. jesh

    AJAX Forum

    And in the name of the technology itself: "Asynchronous JavaScript And XML". Ostensibly, you're supposed to be able to return XML from the server and get at the XML using .responseXML but I've only had luck with .responseText. And I agree with most here that if you have an AJAX question, just ask it in either the javascript forum or in one of the server scripting ones.
  20. jesh

    Email Problem

    In the last part of the code, does mail($email,$subject,$message,$headers) return true so that you see the "You have successfully registered...." message? Or does it return false?
  21. jesh

    Link

    aspnetguy's got it, but if you want to look up more information about it, try searching for "anchor", "name", and "hash".This page of the HTML tutorial also explains it a bit: http://www.w3schools.com/html/html_links.asp
  22. jesh

    loop problem

    It's generally not a good practice to put database connections in loops. It would be better if you could alter your SQL so that you only made one or two calls to the database - outside of the loops.For example, if your first query returned a list of IDs for the buddies, you could loop through those results to convert them to a comma delimited string. Then, you could call your database again with the WHERE clause something like: WHERE u.user_id IN (3,6,12,24,42)rather thanWHERE u.user_id = 3Then, when you get those results, you can loop through them to display them on your page. This keeps the database calls outside of the loops and minimizes the number of calls that need to be made to the database.
  23. Try changing <span id="txt"> </span> to <div id="txt"> </div>.
  24. x is just a variable, you could name it "goondu" if you wanted. txt is the ID of your input element.
×
×
  • Create New...