Posts

Showing posts from 2016

XML to String with UTF-8 encoding

Was having some issues trying to post with some xml data in utf-8 format, since it kept coming out in utf-16 even though I would set the contenttype and other settingsand somehow ignoring them.  I found an article that gave me a solution where they create a class that overrides the encoding of the string writer to utf-8 and that worked. ......  Dim sb = New StringBuilder()             Using writer As StringWriter = New StringWriterUtf8(sb)                 xmlDoc.Save(writer)             End Using             Return sb.ToString() ....... then in a class    Public Class StringWriterUtf8         Inherits StringWriter         Public Sub New(sb As StringBuilder)             MyBase.New(sb)         End Sub         Public Overrides ReadOnly Property Encoding() As Encoding             Get                 Return Encoding.UTF8             End Get         End Property     End Class ....... http://rlacovara.blogspot.com/2011/02/how-to-create-xml-in-c-with-utf-8.html

Telerik RadGrid - Group Continued Message in Group Header When Paging Off

So using the Telerik RadGrid is pretty great, but it does seem to have its share of issues.  Not finding any serious issues though it is quite flexible. The odd message "GROUP CONTINUED FROM THE PREVIOUS PAGE. SHOWING 1 OF 2 ITEMS.)" would show up in one of my group headers even when paging was off with  AllowPaging="false"  in the top RadGrid section and in the MasterTableView.  Placing the GroupContinuedFormatString="" worked fine like below. <GroupingSettings GroupContinuedFormatString=""  CollapseAllTooltip="Collapse all groups"></GroupingSettings> This will not work, at least it does not in mine, it actually crashes the page.  <GroupingSettings  IgnorePagingForGroupAggregates="true" ></GroupingSettings> ------- Update Seems like this may not be enough to get rid of the problems.  Some other messages are creeping in there.

Telerik - Custom Group Footers In RadGrid

As anyone that has dealt with this knows Telerik only supports a single Group or Header Template.  So what happens when you want to change them?  You really only have two options from what I have seen.  The first option is to have something in the data that is brought back that you can use in the designer code in the form of a conditional.  Too bad I do not see a way to check the data based on level like some sort of ParentID like some people have done.  If the ParentID is null  It would look something like below where you check it in the designer: < asp : Label runat = "server" ID = "Label2" Text = '<%# "Number of items in group: "+ (((GridGroupHeaderItem)Container).AggregatesValues["AvailableUnits"]) %>' Visible = '<%# ((((GridGroupHeaderItem)Container).AggregatesValues["AvailableUnits"]) != null)%>' > Or you can use the code behind to really get at the groupIDs like this per

CSS Transitions - Only Complete Half of the Cycle

Starting to learn CSS Transitions and I have to say they are great!  When learning one thing that I encountered was that the transition would not smoothly rewind after completing half the cycle.  So for instance, smoothly changing the color to another, but when I remove the mouse from the element it reverts back without any transition.   As I am sure most of you have guessed, I was not placing the transition elements in the correct spot.  I was placing them in the hover event, while they need to be in the default state.  Looks like translations need to put in the CSS event.   Also, using -Prefix-Free makes all this stuff easier too, where you do not need to add the prefixes for each browser. Ref: https://www.sitepoint.com/community/t/webkit-transition-working-in-only-one-direction/7223/3 https://leaverou.github.io/prefixfree/

Asp.Net - Restricting File Upload Size Client Side

So the problem I encountered was that the site would throw an ugly "maxAllowedContentLength exceeded" error when a user would try to upload a file beyond a certain size.  One of the difficulties with this is that the error is thrown before it even gets to an event, so you cannot try to handle it there. One solution that worked locally for me was to modify the web.config in two places, I will link that page below.  Too bad for me that solution did not work on the server for some unknown reason.  I had also tried handling it in the global.asax, but DNN, our CMS, is somehow preventing that from working.  I will link that too below.  So then I turned to a client side way of restricting it.    The way the client side restriction works is that it uses a newer functionality of html5 that allows most browsers to get the file size.   Older browsers will not work with this, but at this point I am fed up with this and DNN. Also if they disable Javascript they can upload files larger, b

Bootstrap Modal Popup is Grayed Out

The popup shows up, but after it pops up the whole page becomes unusable.  So not only was it not displaying right, the whole page is frozen.  I found a StackOverflow post, below describing how the popup may have that behavior when it is nested inside elements that have positioning elements, which fits with previous experiences I have had.  One of the answers described how appending the modal popup to the body of the page  "$('#mytModal').appendTo('body');" would be a way of getting it out of any positioning elements.  Previously on a different page I had moved it out of some divs and it worked right.  However in this particular site the modal is in a ASP.Net site as a user control where the "offending" positioning element is in the master page and it contains the user control.  I stuck the script in the user control, but the behavior was the same.  When I used Firebug I saw that I was getting a "$ is not defined" message. With Jquery we ne

Windows Forms - DataGridView Button Columns Not In Order

The problem was that a Button column would refuse to be in the right place.  The other columns would order properly but not that button column.  So the idea is to use this Display Index as stated in the msdn link below.  One other thing that needs to be done is to set the AutoGenerate Columns property to false as well. dg.datasource = dt  dg.AutoGenerateColumns = False and then dg.Columns("col_name").DisplayIndex = 0 etc https://msdn.microsoft.com/en-us/library/wkfe535h(v=vs.100).aspx https://social.msdn.microsoft.com/Forums/en-US/e417afad-320b-49d8-9e00-3fec5f360fde/datagridview-displayindex-doesnt-keep-positions?forum=winformsdesigner

MVC: Parser Error Message: Could not load type "X.Y"

After updating the .edmx file to include a couple more objects from the database, I started to get a strange error in the global.assax file stating it could not load the namespace of my project.  I tried many of the solutions on that page, but none helped me. The solution to my problem was that the EF was renaming one of the objects to plural case so it added an "s".  I had a couple Linq statements that were erroring out after that.  Once I renamed that object back to what I wanted it the project worked fine. http://stackoverflow.com/questions/1598829/parser-error-message-could-not-load-type-testmvcapplication-mvcapplication

BDOS With VirtualBox 5.x and old VMWare 7.x Network Adaptors Incompatible

So similar to other issues in the forums with other incompatible network adaptors the version of VMWare I had on my pc would not work with the version of VirtualBox 5.x well.  I would get BDOS on waking up after Sleep, or sometimes after restarting or sometimes in the middle of working.  My VMWare install was on a drive that died so the uninstall would not work through my Windows 7 machine.  I had to go in and do a manual uninstall basically for the VMWare.  I did not do a complete uninstall by messing with the registry, but I did stop the related Vmware services and uninstall the network drivers.   After I did that no more blue screens of death . Edit: After a day or two. I started getting other errors.  Darn.  I have spent too much time on this, I think I am going to try and go back to VMWare.

Add Application Pool to Folder Permissions

Keep forgetting how to add these so making a quick post on it.  Also remember to add it to another other folders that your 3rd party applications might need. Ex: IIS APPPOOL\{your app pool} IIS APPPOOL\DefaultAppPool http://stackoverflow.com/questions/7334216/iis7-permissions-overview-applicationpoolidentity http://serverfault.com/questions/81165/how-to-assign-permissions-to-applicationpoolidentity-account

Asp.net Publishing Broke Site - "App_WebReferences is not allowed because the application is precompiled"

When publishing site to live, trying to go to site gives a Server Error – Runtime Error.  Looking in the Application logs on the server  gave " The directory App_WebReferences/ is not allowed because the application is precompiled."   This was causing a bit of stress to a programmer in a our company since he tried to publish a change during business ours.   Solution http://stackoverflow.com/questions/9892646/how-publish-my-web-site When publishing the options that work are to have “Delete all existing files prior to publish”, and “Precompile during publishing” checked.  And “Exclude files from the App_Data” unchecked.

Race Condition - Resolved Through ADO.Net SQL Transaction

In our site there is a Shared (aka static) class that clears and then modifies a commonly used Table in a SQL Server Database.  The issue was that we would occasionally throughout the day get errors saying that "such and such record" could not inserted because it already exists.  We put in logging in between the statements to try and debug the thing since we could not seem to duplicate the error locally.  We noticed that in one example a single user had somehow two processes that were in lock-step through the function.  Both would clear the table, then both would attempt to insert the same data to it.  When the second process would attempt to insert it would blow up. Basically the resource is shared and needs to be locked so it is not modified by multiple users at the same time. http://stackoverflow.com/questions/34510/what-is-a-race-condition This article was very useful in creating the transaction that resolved my issue.  Ideally I would have preferred to have used a tr

Prevent Multiple Submissions of Forms in Asp.Net

Here is the issue. You have a form and someone double clicks the Submit button, and curiously enough you have two forms that were submitted!  My first thought was to disable the button on click with javascript, and then when the page loaded again the button would be enabled, but that was a no go.  Asp.Net does not fire events for disabled buttons. Went looking around and found a page that suggests using a variable to check to see if it was submitted or not in javascript.  As far as I can tell this is the best way of preventing this issue.  If they have javascript disabled however then it might be a problem though, but I am not even going to worry about those < 1% individuals. I changed their javascript function to not use the .Net markup inside the javascript to get the clientID.  I prefer making the ClientIDMode="Static" and having just pure javascript in the function.  var isSubmitted = false;     function preventMultipleSubmissions() {         if (!isSubmitted)

DNN Site Crawler - LuceneController is disposed and cannot be used

http://www.dnnsoftware.com/forums/forumid/198/threadid/527555/scope/posts/threadpage/2 Found out our app pool is recycling every minute or so due to unrealistically low virtual memory settings, and that was causing problems.  That Site Crawler seems to be used for when you use the site search functionality.  However I have disabled that Site Crawler in HOST->Scheduler which we do not use, and that got rid of the error.

Sql Server - Cannot Expand Database In Object Explorer

So you can remotely connect to the server and see the restored database but when you click to expand it and view the tables it throws an error.   An error like not available in security context or such other such helpful information.  The problem in my case is that the user existed, and it had all the proper security.  I ran the change users proc on the user...or so I thought.  Actually on the upper left somehow the database selected was master. Good thing for co workers that can point out my mistake.  So, my fault I guess, although these orphaned users are strange... EXEC sp_change_users_login 'Auto_Fix', ' user ' http://dbadiaries.com/using-sp_change_users_login-to-fix-sql-server-orphaned-users