.net-2.0

TextBox causes Button Postback in ASP.NET

我的梦境 提交于 2019-12-10 14:32:45
问题 ASP.NET 2.0, testing in FF3 and IE7. When I hit the 'enter' button from a text box the corresponding "OnClick" event for the first ImageButton in the page is fired. If I remove that image button, it fires the next ImageButton OnClick event on the page. From the FireBug console, if I use JavaScript to submit the Form, this does not happen. But for whatever reason hitting enter from the textbox triggers the unrelated ImageButton event. I found this question which had a similar problem, however

get object type and assign values accordingly

只谈情不闲聊 提交于 2019-12-10 14:16:32
问题 I have an arraylist that gets different type of values in it, 1st value-> string ,2nd value-> datetime , 3rd value--> boolean and 4th value is int , how do I find thier type and assign those values accordingly, any help is appreciated:) here is my Code: foreach (object obj in lstTop) { if(obj.GetType() == string) {do this...) else if(obj.GetType() == DateTime) {do this....} else if(obj.GetType() == bool) {do this....} else if(obj.GetType() == Int) {do this....} } Thank you all, my Final Code:

How to avoid a stack overflow?

こ雲淡風輕ζ 提交于 2019-12-10 13:49:58
问题 I compile my code using CSharpCodeProvider, and dynamically create instance of some class in result assembly. Than I call some method. If the method has recursion I get StackOverflowException and my app terminates. How do I avoid this? using System; using System.Runtime.Remoting; namespace TestStackOverflow { class Program { class StackOver : MarshalByRefObject { public void Run() { Run(); } } static void Main(string[] args) { AppDomain domain = AppDomain.CreateDomain("new"); ObjectHandle

Does PostedFile.FileName work differently in .Net 4.0?

a 夏天 提交于 2019-12-10 10:19:42
问题 I'm working on an ASP.Net site which allows users to link documents using a UNC path. This site is used by a customer of ours for internal processes, so all users on their domain should have access to the UNC path. When a user wants to add a linked document, they select the file using a FileUpload control. Previously in .Net 2.0, the control's PostedFile.FileName property returned the filename and the full UNC path. Now we are using .Net 4.0 and it only returns the filename. Here's my main

Dynamic WHERE clauses in a SqlDataSource

坚强是说给别人听的谎言 提交于 2019-12-10 09:43:20
问题 I'm using a SqlDataSource in a very simple application. I'm allowing the user to set several search parameters for the SDS's select command via TextBoxes, one TextBox per parameter (think txtFirstName, txtLastName, etc). I'm planning on using a button click event handler to set the SqlDataSource's SelectCommand property which by default will return all records (for my purposes here). I want to refine this select command to possibly add one or more WHERE clauses depending on if the user enters

CLR 2.0 vs 4.0 performance?

半世苍凉 提交于 2019-12-10 07:54:13
问题 Will a .NET program compiled for CLR 2.0 run faster if running unden CLR 4.0? app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" /> <supportedRuntime version="v2.0.50727"/> </startup> </configuration> 回答1: Typically, no - it will be identical. By default, the CLR 4 runtime will load the CLR 2 runtime to execute your CLR 2 code base. Forcing execution under CLR 4 requires setting

Reading a large number of files quickly

删除回忆录丶 提交于 2019-12-10 03:50:37
问题 I have a large number of (>100k) relatively small files (1kb - 300kb) that I need to read in and process. I'm currently looping through all the files and using File.ReadAllText to read the content, processing it, and then reading the next file. This is quite slow and I was wondering if there is a good way to optimize it. I have already tried using multiple threads but as this seems to be IO bound I didn't see any improvements. 回答1: You're most likely correct - Reading that many files is

Is it possible to initialise a New System.Collections.Generic.Dictionary with String key/value pairs?

爱⌒轻易说出口 提交于 2019-12-10 00:42:34
问题 Is it possible to create and initialise a System.Collections.Generic.Dictionary object with String key/value pairs in one statement? I'm thinking along the lines of the constructor for an array of Strings.. e.g. Private mStringArray As String() = {"String1", "String2", "etc"} In case this is turns out to be a syntactic sugar kind of thing, I'd prefer an answer that I can use in .Net 2.0 (Visual Studio 2005), and Visual Basic - though I'm curious if it's possible at all so don't let that put

How can I prevent unauthorized code from accessing my assembly in .NET 2.0?

霸气de小男生 提交于 2019-12-09 17:00:57
问题 In .NET 1.x, you could use the StrongNameIdentityPermissionAttribute on your assembly to ensure that only code signed by you could access your assembly. According to the MSDN documentation, In the .NET Framework version 2.0 and later, demands for identity permissions are ineffective if the calling assembly has full trust. This means that any application with full trust can just bypass my security demands. How can I prevent unauthorized code from accessing my assembly in .NET 2.0? 回答1: As per

Render Translucent/Transparent Overlay

旧时模样 提交于 2019-12-09 16:45:38
问题 I need a fast way to draw an overlay on a screen with transparency support. I've done a lot of searching and found one potential solution (which has its own problems) and another solution that does not fit my requirements; specifically transparency support. I'll start with the latter and then touch on the former. Solution 1 Using a borderless form with a TransparencyKey, this is one of the most recommended solutions I've found and the least helpful. This solution works by having a new Form,