Posts

Showing posts from July, 2015

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 ;         }

Open Modal on GridView Row Command

Notes on  How to Open Modal on GridView Row Command.  The Update Panel is important when doing it this way.  Have the grid and the entire modal within a UpdatePanel. In the Columns section   <asp:CommandField ShowSelectButton="True" SelectText="Detail" /> In the markup put function to <script type = "text/javascript">  function openModal() {         $('#detailModal').modal('show');     } </script> In the row command  protected void grdDetail_RowCommand(object sender, GridViewCommandEventArgs e)     {         if (e.CommandArgument == string.Empty)         {             return;         }         int index = Convert.ToInt32(e.CommandArgument);                    if (e.CommandName.Equals("Select"))         {                              ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OpenDetailModalScript", "openModal()", false);         }     } And to h

Vertically Align Bootstrap Modal Popup

Very nice.  I would not have been able to come up this nice of a solution.  Definitely will use. http://stackoverflow.com/questions/18053408/vertically-centering-bootstrap-modal-window " This does the job : http://jsfiddle.net/sRmLV/53/ It uses a helper-div and some custom css. No javascript or jQuery required. HTML (based on Bootstrap's demo-code ) <button class = "btn btn-primary btn-lg" data-toggle = "modal" data-target = "#myModal" > Launch demo modal </button> <!-- Modal --> <div class = "modal fade" id = "myModal" tabindex = "-1" role = "dialog" aria-labelledby = "myModalLabel" aria-hidden = "true" > <div class = "vertical-alignment-helper" > <div class = "modal-dialog vertical-align-center" > <div class = "modal-content" > <div class

GridView Asp.net with BoundField and Template Example

Since I sometimes forget. The boundfield should have the SortExpression in order to sort.  Using the template allows you to calls at least protected functions on the data coming from the data source.  Need to add the LinkButton in order to sort, with the CommandName and CommandArgument with "Sort" and the datafield name respectively.  <asp:GridView             ID="gvName"             runat="server"             DataSourceID="sdsSpName"             AutoGenerateColumns="False"             AllowSorting="True"             GridLines="None"             Width="100%"             CssClass="myTableCSSClasses"             EmptyDataText="No data found">             <Columns>                 <asp:BoundField DataField="Status" HeaderText="Status" SortExpression=Status" />                 <asp:BoundField DataField="stateProvinceAbbrev" HeaderText

No One should ever import images from Access ever again

Hello, going to explain exactly what is going on with these logos, if/when this becomes an issue again.   And why from now on No One should ever import images from Access ever again . When inputting an image into the database through Access, Access formats the image into something called an OLE Image Object.   You can tell an OLE Image Object by looking at the value in the database in the table, because they start with 0x151C.   The reason why loading it through Access is such an issue is that it makes it impossible to load it normally through .Net applications, meaning you cannot view them through a desktop programor through any of our sites , you can only view them in Access and Crystal Reports.   Access adds data to the beginning and end of the image for an undetermined number of bytes which depends on a number of factors such as the file type and location you loaded it from.   The only way to display such a file is to strip the bytes from the beginning and end of the “