Posts

Showing posts from 2015

SqlHelper: Parameter count does not match Parameter Value count

I had a call to a ExecuteNonQuery that was giving me the error "Parameter count does not match Parameter Value" count.  In my case this error is an incorrect error.  No matter how many times I compared the parameters from the ones in the procedure the number was always the same. In this case the procedure needed a DateTime parameter, but I was incorrectly trying to give it a string.  Then it would throw that error. Once I put the correct DateTime parameter type it worked properly.

JqueryUI Datepicker Widget - Relative Min Max options

Turns out I am needing to have some date range restrictions on my datepicker.  Need user to only be able to select a relative range from today.  Including today and 10 days later, for example: $(".datepickerDateSent").datepicker({ minDate: 0, maxDate: "+10D" }); http://api.jqueryui.com/datepicker/#option-minDate

Asp.net - Output Excel Sheet from Memory Stream

This will allow the user to save the excel doc from the web.         MemoryStream ms = new MemoryStream();        //use whatever to save the excel workbook data to the memorystream         byte[] array = ms.ToArray();           Response.Clear();         Response.ContentType = "application/xlsx";         Response.AddHeader("Content-Disposition", "attachment; filename=test.xlsx");         Response.BinaryWrite(array);         Response.Flush();         Response.Close();         Response.End();

Linq To a DataTable

Not that familar with linq, but this does seem rather promising.  A query to get elements from a datatable. var sd = from myRow in myDt.AsEnumerable()                          where myRow.Field<int>("ID") == cbID                          select myRow.Field<DateTime>("DateSent"); http://stackoverflow.com/questions/10855/linq-query-on-a-datatable

DNN Default Password Reset Link Expiration

So today on a DNN7 installation we encountered a user that could not reset their password through the reset password link.  She then tried the Forgot Password again and went through the reset password process and it worked.  So I assumed that the link was bad or something and I was right. She was trying a password reset link from an email over a day old.  Turns out the default password was set to 60 minutes, and the host is set to 24 hours.On the link below  a user stated you can find the link for the password reset expiration in "Host Settings -> Advanced Settings -> Membership Management".  Now I am going to change the language in the email to reflect that there even IS an expiration to the link. http://www.dnnsoftware.com/answers/how-long-before-the-password-reset-token-expires http://assortedfrustrations.blogspot.com/2015/10/dnn-and-error-login-messages.html

SSMS - Saving Changes is Not Permitted In Designer

Image
So I am trying to save a change to a table I am creating, but Sql Server Management Studio will not let me.  So I get this error below, this "saving changes is not permitted." error. To be able to drop and recreate the table uncheck this.  You can find this by clicking the menu Tools ->Options -> Designers ->"Prevent saving changes that require table re-creation". This fix is all over the place, but I wanted to just show where the option is exactly.

Javascript For Only Allowing Decimals or Integers

To prevent input of other non decimal/integer characters, aka not 0-9 or '.' to a text box you want to look for the keycodes client side.  Having a keypress event on the server side wold be inefficient and silly when you can do it in client side.  If you are trying to validate input you will also need to check server side. This fix in my case was mainly for a minor tool that does not access anything outside of itself.  If the user is intelligent enough to turn off Javascript then they will know why they it does not work.  The tool is hardly used, but if it turns out non-hackers are able to bypass the Javascript and keep getting errors then I will consider doing more server side validation.  So good enough for now. ref: http://www.codeproject.com/Questions/425670/Textbox-only-for-Numeric-decimal-values

Prevent Text Wrap On a Page

Was having some text wrapping going on in a column that really did not need it in a Bootstrap grid.  It would only happen right before the site switched to the mobile view.  Rather than mess with the grids any further I added the following class to that single element.  .nowrap{         white-space: nowrap;     } ref: http://stackoverflow.com/questions/300220/how-to-prevent-text-in-a-table-cell-from-wrapping

Print Preview Using Bootstrap shows HTTP links

100th public post!  Very cool. Was not thinking I would be able to keep up with this blog but I guess I am...  Anyway so we got a complaint from a client about their values missing 10 cents, but their snippet they gave showed a very odd looking site with links everywhere.  So a senior guy looked at it, becuase I had never seen it like that before.  He said he had encountered it sometime last year.  He found a nice stack overflow link for a fix. So what I did was I made the change below to the skin of our site in the bootstrap.css and bootstrap.min.css files.  Note: you may have to clear your cache to see the change in a browser. @media print { a [ href ]: after { content : " (" attr ( href ) ")" ; } } Just remove it from there, or override it in your own print stylesheet: @media print { a [ href ]: after { content : none ! important ; } } ref: http://stackoverflow.com/questions/7301989/need-to-remove-href-values-when-pr

DNN and Custom Error Login Messages

Be forewarned that the error message locations can change between versions in the Language Files.  I have had success by editing it at the "host" level. DNN Password Error Message Locations 1)  Admin - Languages ---- then click Language Editor Local Resources - Admin - Authentication - App_LocalResources - Login.ascx    ref: http://www.dnncreative.com/Forum/tabid/88/aft/16716/[Link] 2) Languages -> Desktop Modules  ->Admin -> App_LocalResources _> Login.ascx 2) Languages -> Global Resources -> SharedResources   a)  Resource Name:   PasswordResetFailed.Text   b) R esource Name:   InvalidPassword.Text   c) R esource Name:   PasswordInvalid.Text ------ Note: You may also need to check your permissions for IIS_IUSRS if you get some kind of file access error.

Bootstrap On Responsive Change Remove a Grid Column

In data grid  in the <Columns> section. The main Bootstrap class is called visible-lg-block.  However in IE please be aware that it causes a dark line on the top of the area with that will appear. Works fine in all the other browsers.  I was able to stop the top dark line with tr{        border-top-style:hidden;    } but then the rows do not have the upper border.  It works fine in all the other browsers.  If there was a way of stopping that dark line in IE it would be fine.  Simply trying to change the border-top color does not have any effect.  Could not find how to stop it from doing that. However it  works fine in a Repeater.  You used a html table.  Use table, then the tbody do not use thead, since the bootstrap will switch the alternating colors starting with transparent instead of grey.  Then use the following for example for the item.  You may also need to use the AlternatingItemTemplate if you want the alternating rows to be different. Example for section in Repeat

DNN 7 Password Change Bug With Whitespace

The problem is that when a user is trying to change their password it will fail if there is whitespace in the username. A simple String.Trim Method would fix this issue. One of our managers could not get tit working. For example "testuser" will work, but "testuser " will not work. Thank you. Steps: 1) As an admin user click "Force Password Change" 2) Logout as admin. 3) login with as the user, and go to the password change screen. 4) Type in the user name but with a space at the end. 5) Input new password. 6) Click Submit. 7) It fails and will say the new password was not accepted for security reasons. Posted this on the dnn community voice area for bugs.

MS Charts Asp.Net Table For Legend

 If you want a table like thing for a Legend you can take a look at the following.  Putting this in the Load event works.  However...this code was never actually used.  Why?  Because it takes up too much chart real estate, and when the pages to a small width the chart resizes too small and becomes unreadable.  Too bad. :(.   ////Create a new legend called "Legend3".          Chart1.Legends.Add(new Legend("Legend3"));           ////Set Docking of the Legend chart to the Default Chart Area.          Chart1.Legends["Legend3"].Docking = Docking.Left;          Chart1.Legends["Legend3"].Alignment = StringAlignment.Center;                   ////Assign the legend to Series1.          Chart1.Series["Series1"].Legend = "Legend3";          Chart1.Series["Series1"].IsVisibleInLegend = true;          LegendCellColumn lccSym = new LegendCellColumn("Sym", LegendCellColumnType.SeriesSymbol, "");          lccSy

Visual Studio 2013 web.config lost all color formatting

Not something I would have thought would be a large problem, but turned out to be.  Reading that XML quickly without some kind of font color scheme takes forever and is error prone.  For me at least hah.   Found a post on SO about someone saying their VS had lost that ability for their XAML files and that someone suggested to reset the user settings.  It worked for them for XAML, and that method worked for me for my XML.  Sweet.  Just open up the command prompt for the relevant visual studio and type in  devenv /resetuserdata. http://stackoverflow.com/questions/13582209/no-xaml-color-formatting-in-visual-studio-2012

Some Notes for Converting ASP pages to Asp.Net (ASPX) Pages

Some old checklist I had made a while back on converting an asp page to asp.net.  It was kind of a pain, and it popped up again, because a fellow co worker was asking about it.  It might be of some use. 1)       First I created an aspx page, then copied the asp over it excluding the original ASP directive at the top. 2)       Make sure class names, filenames, locations are correct. 3)       Need to use Codefile instead of CodeBehind in the Page directive. 4)       Make sure the language in the directive matches the code.   In that asp page I was converting the language was “C#”, but the script language was “VB”. 5)       Since this is asp.net make sure you are using Partial keyword in code behind for the class declaration type. 6)       May need to have new includes. 7)       “ '__o' is not declared. It may be inaccessible due to its protection level.                 Will show as a compiler Error, but is not actually an error that will stop you from running the

Dealing with Inconsistent Capitalization In Data

I like the simple answer: http://www.u-convert.com/ and then select "To UpperCase".  The problem of trying to get correct capitalization on names is something I saw on a couple blogs.  Some used recursion and others just did more simple manipulations.  However, if they are all caps then everything is consistent without having any possible complaints from all though McCoy's and DeForest's and similar names.

Asp.net Charts - Url on Series Data Points

 So if you have an Asp.net chart and need to have some kind of Url over the data point areas (esp the individual bars on a bar chart, or the slices of a pie chart , etc) on the chart itself you can access the individual Points on each of your Series and set the Url property.  Another option is to set a PostBackValue which can be accessed in a click event of the chart.  This actually ended up being scrapped because I found that if you resize the image then the click areas do not match up with the image anymore.  With our responsive setup have the images be responsive was a necessity as well.  Normally the asp.net chart images have a fixed width and height...well now I know why.    DataTable dt= GetSource();         if (dt.Count != 0)         {                           int i = 0;                 for (i = 0; i <= dt.Rows.Count - 1; i++)                 {                     string x = (string)dt.Rows[i]["name"];                     decimal y = (decimal)dt.Rows[i][&quo

Fun With Automate 9 Errors

Encountered several issues yesterday within Automate 9. One problem was that the server was somehow not letting go of some files on one of the tasks resulting in the error "FTP Failed (Error: Access denied, file is locked in another upload session or by another application (550)).  The solution to that was to restart the server since I could not see what was holding on to it.  There might be other programs I could have gotten to help me identify what was holding it, but I was kind of under pressure. Another FTP task was giving some obscure Winsock Error (?)  in response to attempting to encrypt and move a file.  The error wa s "Cryptography failed (Error : File system operation failed with error (error code is 103429))". This seemed to be resolved by running the task as Administrator, or it was resolved by the rebooting of the server. On some other FTP tasks I was getting "Could not determine current location error".  This was happening when trying to

String format for Money With No Cents.

Change the display format from {C} to {C0} which means money format but no cents.  Simple but easy to forget...

Common Table Expressions CTE in SQL SERVER - Get Top Value of a Group

So I had a problem where one of the companies we work with wanted data for a column, however they wanted a single example.  However in our system we can have multiple entries for that column. I needed to get a single example other wise when joining would show other many more rows than necessary for what they wanted.  SO I turned to Common Table Expressions (CTE)s. Although turned out that because I was excluding data one of my bosses said just not to send that field, because it would be similar to misinformation. Hah. ;With PBs(accountID,PBName,rn) AS ( select ACV.accountID, B.lastName + ', ' + B.firstName + ' ' + B.middleInit, ROW_NUMBER() OVER (PARTITION BY acv.accountID ORDER BY acv.accountID DESC) as rn FROM  ACV --- etc joins where --conditions group by ACV.accountID, B.lastName + ', ' + B.firstName + ' ' + B.middleInit ) SELECT --other fields PB.PBName FROM  ACV ---joins LEFT OUTER JOIN PBs

CSS Child vs Descendant Selectors

Needed to style the paging elements "Next, First" etc, on a gridview pager.  I was having some trouble selecting the right elements.  No wonder becuase when you view where the actual Next element is in the html below you really have to go out of your way to get to the a element.  The descendant operator "s1 s2 {styles}" works, although I am not sure about its speed. .alphaLink td a {     padding:5px; } < tr   class =" alphaLink " >   < td   colspan =" 7 " >     < table >       < tbody >         < tr >             < td >              < a   href =" javascript:__doPostBack('dnn$ctr842$CSearch$gvCSearch','Page$Next') " > Next </ a > .... ref http://bytes.com/topic/asp-net/insights/942081-how-change-pager-style-gridview http://stackoverflow.com/questions/1182189/css-child-vs-descendant-selectors

Microsoft Chart Will Not Resize with Bootstrap

I was having trouble resizing the Microsoft chart that comes with asp.net.  I am using Bootstrap but oddly enough it will only resize the width of the chart image not the height.  When you look at the page source the image is rendering with inline style width and height.  To have the bootstrap img-responsive class work properly, the width and height of the image should not be set according to the posts I was reading.  Not setting the height and width of the image did not work, it would default to 300x300, so I resorted to a Jquery solution which removes the styles from the element when the page is ready. Note: I was able to have the chart in a Bootstrap grid without the img-responsive and it would auto resize the image once the inline styles on it were removed.  Neat. <script>  $(function () {         $("#<%= Chart1.ClientID %>").attr('style', '');     }); </script>  ....    <asp:Chart ID="Chart1" runat="server&

Get Row Count from SqlDataSource after Filtering

Select from the sqldatasource and convert the output to a dataview, then place the same filter you are using, and get the count.  Remember to place this code in the databound event.  protected void gvCurLookup_DataBound(Object sender, System.EventArgs e)     {         System.Data.DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);         dv.RowFilter = SqlDataSource1.FilterExpression;         int RowCount = dv.Count;         if (dv.Count > 0)         {             this.lblMsg.Text = dv.Count + " Books...";         } } ref http://www.c-sharpcorner.com/UploadFile/scottlysle/using-filter-expressions-with-an-sql-data-source-in-Asp-Net-C-Sharp/  

When to Use !important in CSS

 Had this really irritating problem where I simply could not seem to change the color of the text to black.  Put !important and then it worked. http://stackoverflow.com/questions/5701149/when-to-use-important-property-in-css input , select {             color : black !important ;         }