Jump to content
Xtreme .Net Talk

bri189a

Avatar/Signature
  • Posts

    1014
  • Joined

  • Last visited

Everything posted by bri189a

  1. Okay, in C# 2.0 I'm having trouble figure out how to close down a handle properly when it has timed out: //Invoke delegate with callback IAsyncResult iar = write.BeginInvoke(format, arg, callback, null); //Give it 30 seconds to complete iar.AsyncWaitHandle.WaitOne(30000, true); //If it hasn't completed, terminated the call if(!iar.IsCompleted) { iar.AsyncWaitHandle.Close(); } else { //Properly clean up write.EndInvoke(iar); } So after closing the handle anything in the delegate that is currently executing finishes executing and the system still tries to fire the IAsync delegate (callback) which generates an error because the wait handle has been closed. So really there's two things...how do I stop execution of the asynchronous call IMMEDIATELY, and second keep the asynchronous call from being executed...I was looking for a 'Cancel' method, but the 'Close' method is the best I could get. I may be also doing this wrong too...asynchronous calls aren't my strong point. Also I know you are suppose to call EndInvoke when you use BeginInvoke, but with the Close method I couldn't...if that's not correct please let me know.
  2. a "Set" generic collection. usage: Set<CheckBox> weekdaySet = new Set<CheckBox> (new CheckBox[] {chkMonday, chkTuesday, chkWednesday, chkThursday, chkFriday} ); Set<CheckBox> weekendSet = new Set<CheckBox> (new CheckBox[] {chkSaturday, chkSunday} ); Set<CheckBox> allWeekSet = weekdaySet & weekendSet; the class code: using System; using System.Collections.Generic; namespace ObjTec.Collections { class Set<T> : List<T> { public new T this[int index] { get { return base[index];} set { if (this.Contains(value)) throw new ArgumentException("Duplicate object."); base[index] = value; } } public new void Add(T item) { if (this.Contains(item)) throw new ArgumentException("Duplicate object."); base.Add(item); } public new void Insert(int index, T item) { if ( this.Contains(item)) this.Remove(item); this.Insert(index, item); } public new bool Remove(T item ) { if (!this.Contains(item)) return false; return this.Remove(item); } public new bool Contains(T item) { if (item == null) throw new ArgumentException("Set cannot contain null items"); return base.Contains(item); } public static Set<T> operator & (Set<T> lhs, Set<T> rhs) { return lhs.Union(rhs); } public Set<T> Union(Set<T> aSet) { Set<T> unionSet = new Set<T>(); Set<T> sourceSet = null; Set<T> mergeSet = null; sourceSet = aSet.Count > this.Count ? aSet : this; mergeSet = mergeSet == aSet ? this : aSet; foreach(T item in sourceSet) unionSet.Add(item); foreach(T item in mergeSet) if( !unionSet.Contains(item)) unionSet.Add(item); return unionSet; } public static Set<T> operator |(Set<T> lhs, Set<T> rhs) { return lhs.Intersect(rhs); } public Set<T> Intersect(Set<T> aSet) { Set<T> commonSet = new Set<T>(); Set<T> sourceSet = null; Set<T> mergeSet = null; sourceSet = aSet.Count > this.Count ? aSet : this; mergeSet = mergeSet == aSet ? this : aSet; foreach(T item in mergeSet) if (sourceSet.Contains(item)) commonSet.Add(item); return commonSet; } public static Set<T> operator ^(Set<T> lhs, Set<T> rhs) { return lhs.Difference(rhs); } public Set<T> Difference(Set<T> aSet ) { Set<T> result = new Set<T> (); foreach(T item in aSet) if ( !this.Contains(item)) result.Add(item); foreach(T item in this) if ( !aSet.Contains(item)) result.Add(item); return result; } public static bool operator ==(Set<T> lhs , Set<T> rhs) { if (System.Object.ReferenceEquals(lhs,rhs)) return true; if ( ( (object)lhs == null) || ( (object) rhs == null) ) return false; return lhs.Equals(rhs); } public static bool operator != (Set<T> lhs, Set<T> rhs) { return ! (lhs == rhs); } public override bool Equals(object obj ) { if ( obj == null ) return false; Set<T> test = this as Set<T>; if ( test == null ) return false; if ( this.Count != test.Count) return false; if ( !this.IsSubsetOf(test)) return false; if ( !test.IsSubsetOf(this)) return false; return true; } public bool IsSubsetOf(Set<T> aSet) { foreach(T item in this) if ( !aSet.Contains(item) ) return false; return true; } public bool IsSupersetOf(Set<T> aSet) { foreach( T item in aSet) if ( !this.Contains(item) ) return false; return true; } public override int GetHashCode() { return base.GetHashCode(); } } }
  3. don't carry mutliple fields over as a single foreign key. Implement a surrogate key in the parent and bring that over as the foreign key.
  4. Try this: http://www.obj-tec.com/MSDNForums/ObjectPicker.zip
  5. That's cool, but it just raises more questions. If they're going to be able to make an addition to do these things, why can't I manually do them now? I'm honestly disappointed at MS for taking that away. I'm sure it has to do with these partial classes and how they're used deep down to make the MSIL - but if a page should have a code behind, and that code behind is a class, then I should be able to make that class public and instantiate it anywhere in my project. On those same lines, I should be able to declare controls on my page publicaly accessible - not that I approve of that kind of design - but I should at least have the ability to.
  6. So by luck I found that if you have a user control you want to reference called 'MyUserControl' you can create and instance of it through ASP.MyUserControl_ascx for pages that need it. However I haven't figured out how to get the page - where they've hidden that class. If you're in the page your referencing, there it is, but outside of it you can't. You also can't put your code behind in a namespace because of the whole partial class thing...you'll get a compile error. Does anyone know how you could create an instance of the code behind of page file? Or how to change the namespace - or even have one for a code behind - they don't seem to have one right now. I have something that in the future I'm going to need this functionallity - I have a set of classes that basically have an association (in UML) between the two and I'd hate to redesign a functional set of pages because of this now 'missing' ability.
  7. So the answer to this one is that the ObjectDataSource has a propert called ConvertNullToDBNull - you need to set this to false which is kind of non-intuitive - to me at least. What's it saying behind the scenes is that whenever you have a null value for a parameter it's going to being passing DBNull to the underlying business object - in my case a DataSet/TableAdapter. The TableAdapter parameter has the System.Nullable structure (or whatever you want to call it) but apparently DBNull isn't one of those. It's weird, I can't fully explain it yet but this was the work around.
  8. So if DateTime is suppose to be Nullable in 2.0 why do I get this error (nullable value types is suppose to be something support in 2.0 I believe)? Basically I have a form where I'm updating the date, the date can be null in the database if it's not used, meaning I must be able to set the field to null from the front end application. Basically what I'm doing in my DataList is if the text box that represents the Date is blank, I don't set the Update Parameter. I have tried the 'ConvertEmptyStringToNull' property to both true and false, both get the same errors. I hate to have to do a bunch of special if statements looking for DateTime.MinValue - but if I have to do it so be it. But now in my stored procedure I have to look for that value and set the value manually to null in the stored procedure; which is just plain bad. Any help would be appreciated.
  9. I found that if I don't use a SiteMapDataSource then I don't get the error. I can continue using the SiteMapDataSource if I put .ctl00_SiteMenu_1 { .color: White !important; } in my style sheet.
  10. The following on my master page results in blue text, not white. Is this a bug? <td style="height: 24px"> <div style="position: absolute; top: 77px; left: 158px;"> <asp:Menu ID="SiteMenu" runat="server" Orientation="Horizontal" DataSourceID="SiteMapDataSource" Width="180px"> <StaticMenuItemStyle ForeColor="White" /> </asp:Menu> <asp:SiteMapDataSource ID="SiteMapDataSource" runat="server" ShowStartingNode="False" /> </div> </td> It's weird, it generates the following mark-up for the anchor element: <a class="ctl00_SiteMenu_1 ctl00_SiteMenu_3" href="/VSDOTNET/Project1/Page1.aspx">Page1</a> How is this a valid CSS class for one (notice the space in the class name)? And two this definitely doesn't say 'style="color: White;"'
  11. how about you have your javascript function called with the 'this' as an arugument: 'In ItemDataBound If e.Item.ItemType = ListItemType.EditItem Then Dim dgi as DataGridItem = DirectCast(e.Item, DataGridItem) Dim cntl as Control = e.Item.Cells(0).FindControl("DropDownList1") If Not cntl Is Nothing Then DirectCast(cntl, DropDownList).Attributes.Add("onmousedown", "MyJavaScriptSetCurrentValue(this)") DirectCast(cntl, DropDownList).Attributes.Add("onchange", "MyJavaScriptConfirmFunction(this)") End If End If Now you javascript would be something like: var curValue; function MyJavaScriptSetCurrentValue(cntl) { curValue = cntl.value; } function MyJavaScriptConfirmFunction(cntl, currentValue) { if(confirm('Are you sure?')) return; else cntl.value = curValue; } ***Note this may not be the best method but it will get the job done...you might want to take the time to do something a little more robust like setting a hidden input tag to the current value that has a similiar name, or something like that. Hope this helps.
  12. Well there are a couple of solutions to this problem. One use a AJAX to only update the things as they need it. This is the ideal solution but is more expesinsive to develop generally. Two is to create you own controls that won't automatically post back or wire up your existing controls (with AutoPostBack set to false) to some javascript that hides/shows options that were intially downloaded but just weren't visible. Sounds like your kind of boxed in by the customer though. Just document everything along with your suggestions and when they sign off on it and if they start complaining down the road you have your CYA material.
  13. From the help file: To position static text or groups of elements 1. On the Layout menu, click Insert Layer. Visual Web Developer inserts a div element with positioning information set. 2. To move the div element, click the selection symbol, and then drag it to a new position. 3. To resize the div element, click the selection symbol, and then drag the resize handles. 4. To add text, click inside the div element, and then type the text. 5. To add elements, drag them from the Toolbox to the div element. Basically what they've done is remove the 'Grid Layout' and replaced it with a div tag that you place absolutely. Then the tags you place with in it will be flow. Alternatively you can just skip all of that and once you drag the control on the page, right click, hit style, and then on Postioning choose Offset from normal (relative) or absolute position. I don't know why they've done this. I'm sure there is a reason, but thankfully I extremely rarely use Grid Layout, so it's not a problem for me. Sorry that you have to deal with it. If you find a reason why, let the rest of us know!
  14. You should be able to hook onto it from the OnItemDataBound...get the controls from that cell and check the text for 'Save' then add from there: If e.Item.ItemType = ListItemType.EditItem Then For Each c As Control in e.Item.Cells(0).Controls If c.GetType() = GetType(LinkButton) AndAlso _ DirectCast(c, LinkButton).Text = "Save" Then DirectCast(c, LinkButton).Attributes.Add("onclick", "myJavaScriptFunctionName") End If Next End If If that's what you've done and .NET still hasn't rendered those link buttons yet try doing it in pre-render and going through the datagrid items collection. If remember right though what I gave you above should be close to working.
  15. I don't think there is an HTML control that represents that kind of behavior so there wouldn't be an ASP.NET control that does. Your talking about having a Access style drop down list where instead of simply highlighting an item you can place a check on it instead right? If you can find a plain HTML control that has that sort of behavior you can create one.
  16. Know this is out of the realm of the forums but I'm sure there a plenty of sould here who have experiance (since all of us professionals usually have some sort of testing software we have to use) and I need some help. It's on Mercury Test Director 8.0. I'm looking for message boards such as this, etc. Respond here or pm me. Thanks.
  17. I work with some very high transaction applications and I've yet to find anything that I need to revert to ASP 3.0 type of posting. If you don't make the control a .NET server control then it won't post back.
  18. Based upon your other posts I HIGHLY recommend you getting Microsoft Press book "Programming ASP.NET" by Dino Esposito. You are obviously trying to do .NET as if it were ASP 3.0 and you will never succeed if you keep that mind set - they are day and night; forget everything you know about ASP 3.0 and VBScript - they will only stand in your way.
  19. This is because your changing the form values. This ASP.NET, not ASP 3.0. You do not change the target or the action in javascript and then post the form. You either post the form and leave all the form attributes alone (server side controls will detect their own changes) with javascript, let the form take care of it's own submission without messing with it in javascript, or do a window.location = in javavascript and use a query string (not recommended).
  20. Well if you are using C# did you: public class subclass : rootclass { public subclass() : base() { } } Or in VB: Public Class subclass Inherits rootClass Public Sub New() MyBase.New() End Sub End Class And in your constructor of your base (root) class is the constructor calling the initalize procedure? Is there anything in your derived (sub) class that needs to be initialized in the constructor call? You have a very open question that I've answered the best I can with the little bit of information that is there. If you want a better answer posts the classes in their entirety (in a zip file).
  21. There is no value property, only checked. If you need to know the 'value' of a radio button because you're show a 'group' of options you typically use a RadioButtonList control. Each radio button is an item in the Items collection property: Me.RadioButtonList1.Items.Add("Choice 1") Me.RadioButtonList1.Items.Add("Choice 2") This will render the following: <table id="RadioButtonList1" border="0" style="width:248px;Z-INDEX: 102; LEFT: 408px; POSITION: absolute; TOP: 288px"> <tr> <td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="Choice 1" /><label for="RadioButtonList1_0">Choice 1</label></td> </tr><tr> <td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="Choice 2" /><label for="RadioButtonList1_1">Choice 2</label></td> </tr> </table> This is a little more html than you're use to see for a radio button group, but as you can see you still have your 'value' and the name groups them together. To determine the change you could either wire up an event to the RadioButtonList_SelectedIndexChanged event in the code behind or query the selected value by: Me.RadioButtonList1.SelectedValue in the code behind. There are also other ways of doing this to, but this is probably closest to what you are looking for. If you want to pre-select a radio button before the page has loaded you can do: Me.RadioButtonList1.SelectedValue = "Choice 1" Again there are other ways to do this - I myself rarely use SelectedValue - but that's because my selections are generally data bound so I don't know what the values are. Hope this helps.
  22. I agree, we probably should continue this post for quite some time just to keep it current. Java is a royal pain in my rear so anything new that has come up in here has been quite helpful. Rules are meant to be broken :)
  23. Yes: Dim c As Control = LoadControl("MyUserControl.ascx") Or Dim btnTest As New LinkButton btnTest.ID = "DynamicallyAddedButton" btnTest.Text = "Test" 'etc. MyPlaceHolder.Controls.Add(btnTest) Or do this with any naming container type of control. Google ".NET Controls.Add" and I'm sure you'll have thousands of hits...
  24. Go to infragistics.com and get their control that will allow you to do this or build your own: http://www.infragistics.com/Products/Gallery/Default.aspx?Product=NetAdvantage&Platform=WebForms
  25. Just change your DOCTYPE tage to the following: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
×
×
  • Create New...