Sunday, February 13, 2011

What is the best way to determine the source of a CSS issue.

Hello,

I have been working on a webpage. It is the first I have actually tried to design using an image and then use proper CSS layout rather than tables.

http://www.roccocammisola.com/proj/brunel/bgimage.html

I have been having issues with the shadows on either side of the main content area. Of course these are only an issue in IE. As you can see the shadow has been cut down to about 10% of its actual height.

With my relative inexperience how do I look for relevant fixes to this issue.

Any help would be very much appreciated.

  • FireBug, the most crucial tool for debugging CSS, amongst other things.

    get it here

    BoltBait : Since he said that his issue is only with IE, how is this going to help him?
    dove : because it is a problem in FF by the looks of it too.
    Chris Marasti-Georg : No, IE7 displays it correctly, as does FF. IE6 is the culprit.
    Larsenal : Whether or not the problem is in IE or FF... you can still use FireBug to understand the way your CSS is being interpreted.
    dove : fair enough. it does look funny in chrome too. but happy to stand corrected and not presume it was a more general error.
    From dove
  • +1 for FireBug

    In this particular case, I'd just suggest a new approach for your shadows. Currently, you have them as items. You typically want to use CSS background images for things like this.

    .mainShadowRight {
    */ your other stuff */
    url('images/mainShadowRight.gif');
    }
    
    From Larsenal
  • IE Web Developer Toolbar It's not as good as firebug in general, but it helps when you have an IE-specific problem.

    From Tom Ritter
  • Your .mainShadowRight CSS class specifies a min-height (which IE6 doesn't understand, and IE7 doesn't always 100% get correctly)

    and as DLarsen pointed out, it appears you are missing the background-image: url(); bit.

    From scunliffe
  • In addition to Firebug, making sure your HTML is valid is an invaluable tool and can minimize CSS headaches. Sometimes your CSS may not work right because there are mistakes in the HTML. The different browsers have different ways of dealing with improperly written HTML which can sometimes make it seem like there's a cross-browser CSS issue. The validator can help you find mistakes in your markup.

    http://validator.w3.org/

    From Andy Ford
  • Thanks for all your answers, seems to have done the trick.

    I think I spazzed out with the upload as I should definitley have had the bg-image stuff there.

    That IE web developer toolbar looks pretty good too as I have firebug and web developer bar for FF.

    From Rocco
  • Another hot recommendation for debugging CSS - CSS Viewer.

    It's a Firefox add-on that allows you to hover over elements in a web page and see their exact style. Often you figure out that the final style was not what you meant, possibly due to some inheritance of styles.

Easiest way to copy an entire SQL server Database from a server to local SQL Express

I need to copy an entire database from a SQL Server 2005 on my server over to my local SQL Express in order to run my application for a presentation. What is the fastest/easiest way to get this done?

EDIT: I have very limited access to my server so I don't think I can access the backup file that I could create so that is out.

  • Back up the database on the server and then restore it locally in SQL Express.

    EDIT: If this is part of your work, surely you can get someone in networks to get you a backup..?

    Collin Estes : Not an option I don't think, because I can't get to the backup file created on the server.
    From Galwegian
  • If you can login to both servers (the Express and the 05 Server) using SQL Server Management Studio then you can do a DB Restore from one database to the other. No need for backup files at all.

    FreshCode : how do you do a restore a database from one server to the other without a backup inbetween? (SQL Server 2008).
    Stephen Wrighton : In instances where neither server is SQL Express, you use sp_detach_db and sp_attach_db or the Import/Export Data Wizard -- http://support.microsoft.com/kb/314546
  • You can use SSIS's database copy wizard, but it's not quick at all. Is there a DBA there that you can ask for the backup file? That will probably turn out to be the fastest way.

  • Depending which versions of SQL Server you are using, you might get some mileage out of the SQL Server Database Publishing Wizard from Microsoft. I've had mixed results with this tool in complex environments, but for most simple database scenarios it is a great tool.

    An example of a scenario where I ran into difficulties was a DB with multiple distinct schemas, each with their own owner and extreme separation between the tables (don't ask...). As I said, though, most other scenarios have been fine.

  • If the database is not too big, you could use the Database Publishing Wizard.

    This is a free tool from Microsoft which creates a complete SQL script of a database for you (not only the tables and stuff, but all data as well).

    You can install the tool on your machine, connect to a remote server and let the tool create the script directly on your machine.

    You can download the Database Publishing Wizard here.

    Mitchel Sellers : NOTE: I have had very bas experience with this....as it has "issues" at times with data relationships.
    Druid : Works great for medium complexity/sized databases! Just wish there was an easier way for the huge, complex ones.
    From haarrrgh
  • Save your database as a sql script

    EMS SQL Manager (for example) allows you to backup your database as a script in a .sql file. It is then possible to run this file against any other SQL server. Just update the first line of the script (CREATE DATABASE ....).

    You can even fully parameter the script in order to include data from complete or filtered tables.

How to use an app.config file when calling a C# dll from C++

How do I use an app.config file for the .Net part when calling a .Net dll from C++ and the data in the config-file must be read at the .Net runtime startup.

If I use have a foo.dll.config that I call from ConfigurationManager.OpenExeConfiguration("foo.dll") I can access application settings. What I would like to do though is to change some information in <system.data>, namely remove a DbProviderFactory and replace it with a new one.

It seems like this can only be done if the code is put in the exectubales app.config file.

But as I am calling the .Net code from C++, I cannot have an app.config for my executable.

Is there some way to specify a configuration file that is sure to be run right after machine.config when the .Net runtime starts, even though I'm calling the .Net dll through C++?

  • You can have myapp.exe.config, and the called .Net assembly will use it, even if myapp.exe is c++ app. I have done this using outlook.exe.config for my outlook addin.

    From Sunny

Binding ASP.NET GridView to an Oracle SYS_REFCURSOR

We have a Procedure in Oracle with a SYS_REFCURSOR output parameter that returns the data we want to bind to an ASP.NET GridView control. I've seen this done before but I can't find the original reference I used to solve the problem.

Here is what the procedure looks like:

create or replace PROCEDURE GETSOMEDATA
(
    P_Data OUT SYS_REFCURSOR
)
AS
BEGIN
    OPEN P_Data FOR SELECT * FROM SOMETABLE;
END GETSOMEDATA;

And for now the GridView is just bare-bones:

<asp:GridView ID="grdData" runat="server" AutoGenerateColumns="true"></asp:GridView>
  • just GooglingIt trying to find out an answer for you, I come across this article.

    maybe it can help you on this matter.

    From balexandre
  • Try something like: (didn't specify which language)

        Public Function GetSomeData() as DataTable
            Dim OrclConn as New OracleConnection("Connectionstring")
            Dim OrclCmd as New Oraclecommand("GETSOMEDATA", OrclConn)
            OrclCmd.CommandType = CommandType.StoredProcedure
            OrclCmd.Parameters.Add("P_Data", OracleType.Cursor).Direction = ParameterDirection.Output 'Or ParameterDirection.ReturnValue
    
            Dim OrclDA as New OracleDataAdapter(OrclCmd)
            Dim RtnTable as DataTable
            OrclConn.Open
            OrclDA.Fill(RtnTable)
            OrclConn.Close
    
            Return RtnTable
        End Function
    
    jamminjulia : This is the correct solution. To bind this data to the GridView, just set the GridView's DataSource = RtnTable and call DataBind().
  • Dim oracon As New OracleConnection("User Id=developer;Password=developer;Data Source=orcl;") Dim ds As New Data.DataSet Dim qry As String oracon.Open() qry = "select * from Employee" Dim adp As New OracleDataAdapter(qry, oracon) adp.Fill(ds) GridView1.DataSource = ds GridView1.DataBind() oracon.Close()

How do you remove a value that has an empty key from an associative array in PHP?

I have a key that appears to be an empty string, however using unset($array[""]); does not remove the key/value pair. I don't see another function that does what I want, so I'm guessing it's more complicated that just calling a function.

The line for the element on a print_r is [] => 1, which indicates to me that the key is the empty string.

Using var_export, the element is listed as '' => 1.

Using var_dump, the element is listed as [""]=>int(1).

So far, I have tried all of the suggested methods of removal, but none have removed the element. I have tried unset($array[""]);, unset($array['']);, and unset($array[null]); with no luck.

  • My guess is that it's not an empty string. Try the following to see what you get:

    foreach ($array as $index => $value) {
        echo $index;
        echo ' is ';
        echo gettype($index);
        echo "\n";
    }
    
    Thomas Owens : I'm doing a print_r on the array, and it appears to be an empty string.
    Thomas Owens : Once I get a working answer, I'll upvote because it is a good thought. But I don't want it to appear that I found a working answer yet.
  • Tried:

    $someList = Array('A' => 'Foo', 'B' => 'Bar', '' => 'Bah');
    print_r($someList);
    echo '<br/>';
    unset($someList['A']);
    print_r($someList);
    echo '<br/>';
    unset($someList['']);
    print_r($someList);
    echo '<br/>';
    

    Got:

    Array ( [A] => Foo [B] => Bar [] => Bah )
    Array ( [B] => Bar [] => Bah )
    Array ( [B] => Bar )
    

    You should analyse where the key come from, too...

    From PhiLho
  • Try unset($array[null]);

    If that doesn't work, print the array via var_export or var_dump instead of print_r, since this allows you to see the type of the key. Use var_export to see the data in PHP syntax.

    var_export($array);

    Note that var_export does not work with recursive structures.

    Thomas Owens : Somewhere along the line, a null value was getting transformed into the empty string. By going to the very source of the array and unsetting null values, I was able to correct the problem.
    Lemming : Congratulations, then. :)
    okalex : From http://php.net/manual/en/language.types.array.php: "Using TRUE as key will evaluate to integer 1 as a key. Using FALSE as key will evaluate to integer 0 as a key. Using NULL as a key will evaluate to the empty string. Using the empty string as a key will create (or overwrite) a key with the empty string and its value;"
    From Lemming
  • Try using var_dump instead of print_r. This may give you a better idea of what exactly the key is.

    From Lucas Oman
  • Please post the code you use to remove the element as well your checker code before and after that line.

    What I'm looking for is something like this:

    var_export($array);
    echo "\n";
    unset($array[""]);
    var_export($array);
    

    Please also post the complete output of both var_export lines.

    I'm looking for something like this:

    array (
      '' => 1,
    )
    array (
    )
    
    Thomas Owens : I have been posting the code right along.
    Lemming : I was (and am) not sure, that you're checking things correctly. No offense, but the code should work. The fact that it doesn't indicated that one of our assumptions is incorrect. To verify, I wanted to see the uncensored, unabbreviated, full code, not a summarized version.
    From Lemming
  • Not sure what to tell you. Running this script

    <?php
    
    $arr = array(
         false  => 1
        , true => 2
        , null => 3
        , 'test' => 4
    //  , ''  => 5
    );
    
    print_r( $arr );
    
    foreach ( $arr as $key => $value )
    {
        var_dump( $key );
    }
    
    unset( $arr[''] );
    
    print_r( $arr );
    

    I get the following output

    Array
    (
        [0] => 1
        [1] => 2
        [] => 3
        [test] => 4
    )
    int(0)
    int(1)
    string(0) ""
    string(4) "test"
    Array
    (
        [0] => 1
        [1] => 2
        [test] => 4
    )
    

    See how the "null" array key was type converted to an empty string?

    Are you sure you are not working with a copy of the array? If you did this call to unset() from inside a function, it's possible that you are.

    This was tested on PHP 5.2.0

    Lemming : Wow, I hadn't realized that null gets converted to an empty string when used as an array key. Crazy behaviour. unset($array[null]) just works like unset($array['']) then.

Saturday, February 12, 2011

Moving from vb.NET (2003) to vb2005 What are some of the benefits?

We are changing from vs2003 to vs2005 and use vb as our primary language, I am looking for some of the changes to VB that will be helpful in our ASP.NET development. Can someone point me to a list (maybe from microsoft?) or provide some of their favaorite differences between the two versions?

  • Better IDE for one.

    From nportelli
  • I found the biggest improvements from .Net 1.1 to 2.0 were generics and yield return for easy implementation of ienumerables.

    From Mendelt
  • WHOA! Not so fast there, buddy! What's the rush? Relax, guy. Give it a few more years.

    Any .NET developer not working version 3.5 of the framework is just wasting time. Every single bit of it... Linq, WPF, lambdas, WCF, GENERICS, I could go on... Every SINGLE bit of it is gold. I'd rather play on a highway than target 1.1. Its like night and day.

    Do yourself and your team a favor... Skip 2k5 and hit 2k8.

    Greg D : Any advancement is positive, organizational inertia can be a pain. I'm still fighting to get colleagues to stop using VB6.
    Will : Organizational inertia in this case is costing developer productivity. And the majority of money brought into my shop is from vb6 apps, as well.
    Joel Coehoorn : generics are in 2.0.
    WACM161 : I agree with the 3.5 statement, unfortunately there is no money to go that far, we already have the vs2005 licenses but have no vs2008 ones and finance dept is unwilling to foot the bill to upgrade
    Will : Yes, generics are in 2.0. I didn't mean to imply you had to go to 2008 to get 'em.
    From Will
  • What's new in VB 2005 (from MS)

    The same topic covered in Code Magazine

    WACM161 : exactly what I was looking for , thank you
    From Torbjørn
  • From a language perspective, the addition of Generics and Nullable types (second link) (built on Generics) was a pretty compelling story for my work. The My namespace provides VB developers with quite a few shortcuts into "somewhat" more complicated features of the system.

    From an ASP.NET perspective, even though they weren't VB-specific, the addition of the Master Page framework and MembershipProvider architecture were also very valuable.

    Here's a fairly comprehensive list from Microsoft of all the Visual Studio 2005, language and major .NET framework changes.

    For what it's worth, you might consider just jumping over 2005 and right into 2008, with .NET 3.5.

    From John Rudy
  • Rick Strahl takes stock of the major changes and provides a personal perspective on some of the highs and lows.

    .NET 1.1 to .NET 2.0 Migration Article 1 Atricle 2

    From notandy
  • I personally find some of the IDE changes to be of the best benefit.

    • The fact that the designer DOESN'T re-format your code as it feels like it
    • The fact that standard layout is DEFAULT rather than grid layout
    • Improvements in intellesence

    In addition to the IDE changes, if I had to pick 1 .NET 2.0 thing that is a huge helper I would say generics.

How do I check if a tag exists in XSLT?

I have the following template

<h2>one</h2>
<xsl:apply-templates select="one"/>
<h2>two</h2>
<xsl:apply-templates select="two"/>
<h2>three</h2>
<xsl:apply-templates select="three"/>

I would like to only display the headers (one,two,three) if there is at least one member of the corresponding template. How do I check for this?

  • <xsl:if test="one">
      <h2>one</h2>
      <xsl:apply-templates select="one"/>
    </xsl:if>
    <!-- etc -->
    

    Alternatively, you could create a named template,

    <xsl:template name="WriteWithHeader">
       <xsl:param name="header"/>
       <xsl:param name="data"/>
       <xsl:if test="$data">
          <h2><xsl:value-of select="$header"/></h2>
          <xsl:apply-templates select="$data"/>
       </xsl:if>
    </xsl:template>
    

    and then call as:

      <xsl:call-template name="WriteWithHeader">
        <xsl:with-param name="header" select="'one'"/>
        <xsl:with-param name="data" select="one"/>
      </xsl:call-template>
    

    But to be honest, that looks like more work to me... only useful if drawing a header is complex... for a simple <h2>...</h2> I'd be tempted to leave it inline.

    If the header title is always the node name, you could simplifiy the template by removing the "$header" arg, and use instead:

    <xsl:value-of select="name($header[1])"/>
    
  • I like to exercise the functional aspects of XSL which lead me to the following implementation:

    <?xml version="1.0" encoding="UTF-8"?>
    

    <!-- test data inlined -->
    <test>
        <one>Content 1</one>
        <two>Content 2</two>
        <three>Content 3</three>
        <four/>
        <special>I'm special!</special>
    </test>
    
    <!-- any root since take test content from stylesheet -->
    <xsl:template match="/">
        <html>
            <head>
                <title>Header/Content Widget</title>
            </head>
            <body>
                <xsl:apply-templates select="document('')//test/*" mode="header-content-widget"/>
            </body>
        </html>
    </xsl:template>
    
    <!-- default action for header-content -widget is apply header then content views -->
    <xsl:template match="*" mode="header-content-widget">
        <xsl:apply-templates select="." mode="header-view"/>
        <xsl:apply-templates select="." mode="content-view"/>
    </xsl:template>
    
    <!-- default header-view places element name in <h2> tag -->
    <xsl:template match="*" mode="header-view">
        <h2><xsl:value-of select="name()"/></h2>
    </xsl:template>
    
    <!-- default header-view when no text content is no-op -->
    <xsl:template match="*[not(text())]" mode="header-view"/>
    
    <!-- default content-view is to apply-templates -->
    <xsl:template match="*" mode="content-view">
        <xsl:apply-templates/>
    </xsl:template>
    
    <!-- special content handling -->
    <xsl:template match="special" mode="content-view">
        <strong><xsl:apply-templates/></strong>
    </xsl:template>
    

    Once in the body all elements contained in the test element have header-content-widget applied (in document order).

    The default header-content-widget template (matching "*") first applies a header-view then applies a content-view to the current element.

    The default header-view template places the current element's name in the h2 tag. The default content-view applies generic processing rules.

    When there is no content as judged by the [not(text())] predicate no output for the element occurs.

    One off special cases are easily handled.