asp net 2.0 EnableEventValidation = False - asp.net

This isn't so much a question as to more of a quick tip on some issues I had with my GridView export to Excel..
So I was having the problem that when I exported a GridView to excel spreadsheet, the spreadsheet was essentially blank however strangely enough a couple fields were filled with a tad bit of html (<div>, </div>).. I couldn't really figure out why that was happening but I stumbled upon a link which fixed my issue:
http://www.codeproject.com/Questions/45450/RegisterForEventValidation-can-only-be-called-duri
So for my solution I just added the EnableEventValidation=False in the top of my form and I neglected to add the bit of Me.EnableViewState = False in the behind code. This worked for whatever reason..
Question: Could someone explain what the heck is going on? I feel like every time I get something working with Asp.net it feels like I am mostly just exploiting bugs in the framework to get code working as opposed to using a logical flow like other frameworks I've used.. I still don't understand how something like this can just 'magically' work now and I have know understanding of the reasons why.
It's like if I were to program: A is in B and B is in C.. Therefore A is in C.
Case 1:
RoR: Ok, A is in C, your right mr. programmer, I get it.
Me: Yay, ok on the the next task..
Case 2:
Asp.net: Must set inheritor for object C.. see stacktrace...etc
Me: oh.. hmm ok I'll google that error:.. 45 min later.. Oh here is something weird that doesn't contain any useful docs... I'll try that. Oh it works! Yaay, but lame. I dun get it.

Related

Checking for form correctness in visual basic

I'm developing a small web app using ASP.net/VB.net4 that contains an important form on one of the pages. I need to make sure that the form is filled out correctly, and have decided to go with custom logic to do this, writing each check by hand and checking every element on the page.
My question is actually more fundamental here -- I have the checks written to make sure that the form passes correctness, but I don't actually know in what programmatical structure to put these checks.
For now, I put the checks in an infinite loop in my Visual Basic code behind.
While (True)
If (...) Then
MsgBox("One or more of your phone numbers is improperly formatted. You will be given 20 seconds to correct this mistake. If the mistake is not corrected in 20 seconds, you will be eliminated. Good luck.")
ElseIf (...) Then
...............
Else
Exit While
End If
End While
Upon hitting the submit button, the loop activates and the checks are completed -- however, there is an issue with this method. When the form is not correct, then my alert message continues to pop up infinitely and does not allow the user to exit out. If anyone knows how to avoid this, that would be an appreciated place to start. Furthermore, the default alert box for VB.net is just ugly and unprofessional, I would prefer something in-browser if possible, rather than just an ugly Windows alert message box.
I've seen a lot of sites now going with a dynamic check; that is, as you fill out the form, if at any point your entry is not formatted properly or is incorrect, you get an automatic alert that tells you this and perhaps the text box color changes to red. I would like to do it this way, if possible, since this seems easier for the user. However, I do not know how to do this and have had trouble finding information online about how to implement this. I believe this is an example of AJAX/jQuery usage but it has been a while since I've used them.
This is a painfully common thing to have to do, forms logic that is. I know there are a million and a half ways to do this, but does anyone have any advice or recommendation on how to implement this? Should I be trying to use vb.net (code behind), javascript, or some other way?

How do you order of operations on Java FX 2 bindings?

EDIT:
I went back and provided a long explanation of each of the below.... Then I started thinking. I think my issue was the division element (getUnitDivisionFactor()) was not observable. I changed this to an observable data type and it all started working. So rather than delete this "stupid question" I will leave it around. Perhaps this will help someone else.
I am using JFXtras 2. There is an "LCD" widget that has a valueProperty binding. It is a double binding. I am binding like this... Which is not working...
xLcd.valueProperty().bind(TinygDriver.getInstance().m.getAxisByName("x").getMachinePositionSimple().subtract(TinygDriver.getInstance().m.getAxisByName("x").getOffset()).divide(tg.m.getUnitDivisionFactor()));
The problem I really need to do the subtraction first..
(getMachinePositionSimple - getOffset()) / getUnitDivisionFactor()
However I am a bit stumped on how to do this in a single binding setup. I think number bindings might be the way to go. However, not quite sure how to set that up right?
Any help would be great.
Riley
The getUnitDivisonFactor() was returning a regular double data type. I changed this to a SimpleDoubleProperty and everything just started working.. See
xLcd.valueProperty().bind(TinygDriver.getInstance().m.getAxisByName("x").getMachinePositionSimple().subtract(tg.m.getAxisByName("x").getOffset()).divide(tg.m.gcodeUnitDivision));

Classic ASP - Detect line number and file from which a function is called?

Our application is made in good (?) ol' classic ASP. Not ideal but it works and it's pretty stable - has been for 10-15 years. It is not particularly well documented in places, such as where a 'translation' (client-controlled piece of text) appears. All we have against a translation is a clientid and translationid, neither of which are particularly helpful. I've tried searching the (10s of thousands of lines of) core code for gettrans(1) (translation 1) and can see that doing this for another 3100 is going to be a nightmare, not to mention inaccurate as there are many functions which are called with a transid passed into them, and then they call gettrans(transid).
My last thought on this matter is the possibility that we could maybe detect, from gettrans, where a function is called from - not just the line number but the file name of the include (thankfully the includes are named usefully so figuring out where a translation is used should not be too hard!). I highly doubt that it would be possible to get the include name on the basis that includes are processed before ASP, but I'll settle for the overall filename and then we can combine the includes to get to the line of code and log the include file name.
I very much doubt this is possible and can't find anything on SO or Google. Does anyone know of any way to achieve this, or have any pointers on what I might try? Thanks in advance.
Regards,
Richard
Most you can achieve is getting the currently executing script, which can be obtained by:
Dim currentPage
currentPage = Request.ServerVariables("SCRIPT_NAME")
When inside included page it will give you the "parent" page.
However getting "callee" information is not possible with classic ASP as far as I know, so you will have to add another parameter to the function being called then change all calls to pass the parameter in order to identify where it comes from. Looks like someone did something similar and called it ASP Profiler, use it at your own risk of course. (Never tried myself)

ASP.NET Using MySQL

OK, I have been trying to write a fairly simple app for days!
My background: I've been a programmer for 30 years, but when it comes to ASP.NET, all I have is a class I took years ago, and even though it was easy for me and I was top in the class, I've forgotten a lot.
However, 80% of my issues has arisen from using MySQL. It seems like MS just doesn't like using non-MS databases very much.
Everytime I run into a new issue, it takes me hours & hours to find a solution.
There was the issue of the SQLDataSource putting square brackets around all table & field names (just the way MSSQL likes it). I got that solved.
There still is the issue of it putting a ? instead of #param-name when building the update & insert queries. The only solution I found here was to go into the code and manually correct the queries.
I still can't get parameter queries to work.
And everytime I turn around, there's a new issue that seems to point me using MySQL. I no long believe the light I htink I see at the end of the tunnel.
Now, using a RAD environment I wasn't real familiar with, I fully expected this project to take me longer. Actually I budgeted for twice as long. But something that I could have whipped out in 1-2 days in VB6, has so far taken me 2 weeks in ASP.NET. I am way behind schedule.
So, my questions are:
Should I just give up on using MySQL and convert my DB to MSSQL?
Is there a 3rd party data source control that is more MySQL friendly?
I've googled this, but couldn't find any. I even looked at Telerik's Radcontrols, who told me that all I have to do is connect their controls to the built in MS SQLDataSource, totally ignoring where my issues lie.

How do I get TextWriterTraceListener to output times much like the standard tracing does?

I'm trying to analyze some running times for various methods in my default.aspx.cs page. I need to use TextWriterTraceListener.
I have it set up so that output is being redirected to the file. However, the data isn't what I want.
As far as I can tell if you simply enable tracing and have the trace appended to the bottom of the webpage you get this nice table with times in between trace calls. It's these times that I care about. An example can be seen here...
http://dotnetperls.com/trace-basics-aspnet
Using TextWriterTraceListener say, for example, I add to the top of Page_Init
System.Diagnostics.Trace.TraceInformation("Begin Page_Init");
and to the bottom...
System.Diagnostics.Trace.TraceInformation("End Page_Init");
here's the output I get...
WebDev.WebServer.EXE Information: 0 : Begin Page_Init
WebDev.WebServer.EXE Information: 0 : End Page_Init
This isn't helpful to me. For one, I don't know what the 0 means. Maybe it's the time, but it's not recognizing anything less than 1 second? I don't know.
I can't find any good resources on this, but I know I have to be missing something, this seems not very useful as is. How do I get times without resorting to some sort of trickery?
Edit: I should note that I found this...
Formatting trace output
However, it seems the consensus is to use log4net or roll your own. Is this really the answer? I'm unsure how this method of tracing could be that useful without any type of timing.
Ok, well writing out Stopwatch values works fine so I guess I'll just do that. It just seems like it should work just the same as when you enable Tracing to the page. I guess not though.
Anyway as far as I can tell, the answer is to use your own method of timing in conjunction with TextWriterTraceListener.

Resources