Friday, July 29, 2011

Navicat SQL storage location on PC

Here is the physical location that Navicat 9.1.8 stores the Query files:

c:\Program Files (x86)\PremiumSoft\Navicat MySQL\*databasename*\

*databasename* represents the name of each data base, so there will be a directory per database
where there are queries defined


I also found another directory that houses sql files.

\users\user\My Documents\Navicat\MySQL\servers\ServerName\DatabaseName

I don't know why there are two locations, unless an earlier version of Navicat created these files in one spot and now creates them in the new one.

But look around in these places if you can't find the files you are expecting

Tuesday, July 26, 2011

Publishing a solution to a site

When publishing a solution to Production, you must take care to update the web config files, as probably you now have the test data base connection strings in the Production system.

Adding programs to Production solution

When adding programs to a Production solution from the development server, not only do you have to copy the files to the proper directory, but you must add them to the solution in Visual Studio.
If not, when your program tries to load the program, you will get a run time error indicating that the resource could not be loaded. This is because it has NOT been compiled and is NOT in the DLL file.

Friday, July 22, 2011

Finding Control on A Page Using Javascript

Here the URL because the Javascript does not seem to appear.

http://www.krissteele.net/blogdetails.aspx?id=92

Enable/Disable All Buttons in a GridView using JavaScript
 9/9/2008      ASP.net      (2)

Sometimes you might find yourself in a situation where you have a GridView that has a number of buttons that you need to enable or disable all at once and don't want to have to force a post back on your users in order to loop through them all. Thankfully with a little client side magic (JavaScript), it's very easy to do just that. 

When a GridView renders on the page, it is simply an HTML table (if you don't believe me, view the source of a page with a GridView yourself) and you can traverse it just like you would any other HTML table using JavaScript. 

Below is code to do a basic version of this in order to enable or disable all buttons in a GridView. First the code gets an instance of the GridView using the ClientID of the GridView (to avoid ID mangling) then create a collection of all input controls in the GridView. Next it loops through each input control and checks the type (this is necessary because input controls include not only submit buttons but also things like textboxes). Finally we either enable or disable the submit button. 


script type="text/javascript" language="javascript"
function disableAllButtons() 
{
    var gridViewID = "<%=gvTest.ClientID %>";
    var gridView = document.getElementById(gridViewID);
    var gridViewControls = gridView.getElementsByTagName("input");

    for (i = 0; i < gridViewControls.length; i++) 
    {
        // if this input type is button, disable
        if (gridViewControls[i].type == "submit") 
        {
            gridViewControls[i].disabled = true;
        }
    }
}

function enableAllButtons() {
    var gridViewID = "<%=gvTest.ClientID %>";
    var gridView = document.getElementById(gridViewID);
    var gridViewControls = gridView.getElementsByTagName("input");

    for (i = 0; i < gridViewControls.length; i++) {
        // if this input type is button, disable
        if (gridViewControls[i].type == "submit") 
        {
            gridViewControls[i].disabled = false;
        }
    }
}
/script>
By changing the value in the getElementsByTagName, it is easy to get things like all the dropdown boxes in a GridView. You can even grab TR and TD elements and walk through each cell of your GridView. I just showed you a very basic example of this, but with a little fine-tuning you can control most any aspect of your GridView. 

I found this particular code useful to include along with the AJAX Animation Control Extender. OnLoading of pages, I can disable all controls on the page to prevent users from clicking something before the page is ready or while a save is occurring and then use the OnLoad event to re-enable all the buttons. 

I haven’t verified this to be sure, but I believe you can port this code over exactly for DataGrids and probably any other Grid or List control. As long as they render as HTML tables (DataGrids do for sure), it should work. 

Click here for a demo of this code in action. This code is simply using a GridView with data from a previous demo I did along with a template column that includes a button in each row. 

-->       

    I modified the above to disable all the input capable fields, so that when the user presses a button and expects some action, all the other buttons are disabled so that, if the system is unresponsive, they will not keep hitting buttons, queuing up more unwanted actions.

        function ChangeAllButtonStates(enableState)
        {
            //var buttonArray = document.getElementsByName("btnComment");
            var buttonArray = document.getElementsByTagName("input");

            for (var a = 0; a < buttonArray.length; a++)
            {
                var myType = buttonArray[a].type;
                var myButton = buttonArray[a];
                var myName = myButton.Name;
                
                if (myType == "submit" || myType == "button")
                {
                    buttonArray[a].disabled = enableState;
                }
            }
        }

Thursday, July 21, 2011

Using UpdatePanel

I had to modify a program where all the data was loaded from the client side using XML and tables. The things I needed to add had already been done in another system and was implemented using the server side code. So, I had three options.
1) Manipulate the new additions from the client side, which would mean I had to start from scratch for that code, since it was server side code.
2) I could move the old stuff to the server side, which would necessitate creating server side code.
3) Leaving the old stuff alone and adding the new stuff on the server side. I chose this option. But it presented some challenges of its own, name managing the state when adding the new fields on postback.
I looked for various options and finally determined to use the UpdatePanel. This would allow me to only update the section of the screen I needed to and the remaining portion of the screen would not change.
Basically, you wrap you controls in the ContentTemplate option of the UpdatePanel and define the triggers that will cause the update for the portion of the screen we are updating.
Another work around involved how the original program functioned. The client code would execute the load mechanism to populate the screen when the program loaded. And because everything else was handled on the client side, it was only invoked 1 time. However, once you start calling server side, this code gets executed on each postback. So, I had to move this code to a function and use the client script manager to invoke this code only on program load.

Wednesday, July 20, 2011

Asp .Net UpdatePanel Info

http://ajax.net-tutorials.com/controls/updatepanel-control/

doPostBack Javascript and .Net implications

Here is an article about calling the dopostback routine in your javascript code.
However, if you only have button controls, the dopostback is not included in your javascript and the eventarguments are not defined.
Provider

Monday, June 16, 2008
Understanding the JavaScript __doPostBack Function
In this article we going to understand the the functionality of __doPostBack function of JavaScript.

_doPostBack Function
Let us take a look at the function.
Listing 1 - _The __doPostBack function


function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
Description
The __doPostBack function takes two arguments, eventTarget and eventArgument. The eventTarget contains the ID of the control that causes the postback and the eventArgument contains any additional data associated with the control. Note that the two hidden fields, “__EVENTTARGET” and “__EVENTARGUMENT,” are automatically declared. The value of the eventTarget and eventArgument are stored in the hidden fields. The two hidden variables can be accessed from the code behind using the forms/params collection.
Using the hidden variables you can also find the ID of the control which causes the postback. All you need to do is to retrieve the value of the __EVENTTARGET from the form parameter collection. Take a look at the code below.
Listing 2 – Getting the _EVENTTARGET hidden field
protected void Page_Load(object sender, EventArgs e)
{
string controlName = Request.Params.Get("__EVENTTARGET");
}
Description
For this code to work you need to add any web server control on the form except for Button and ImageButton control (Discuss it later). Let us add the DropDownList control and set the AutoPostBack property to true and populate the DropDownList with some dummy data. Now, run the page and view the source of the page.
You will see the following line of code.
Listing 3 – DropDownList calling __doPostBack function

The onchange event of the DropDownList calls the __doPostBack function. The ID of the control, “DropDownList1,” is also passed to the _doPostBack function and stored in the _EVENTTARGET hidden field. In the Page_Load I fetch the value of the _EVENTTARGET variable which in this case is the ID of the DropDownList. This way we can find out that which control caused the postback.
What about Buttons and ImageButtons?
You might be wondering about the POSTBACK triggered by the Buttons and the ImageButtons. Well, let us see the code generated by the Buttons.
Listing 4 – Code generated by the Button server control

As demonstrated in the code above, the Button control does not call the __doPostBack function. Because of this, the _EVENTTARGET will always be empty. However, you can find out the ID of the Button by looping through the form controls collection. Take a look at the code below.
Listing 5 – Finding the Button control in the form collection
foreach (string str in Request.Form)
{
Control c = Page.FindControl(str);
if (c is Button)
{
control = c;
break;
}
}
Description
In the code above I iterated through the controls on the page. If the control is of type Button then the loop breaks and the control is returned back to the user.
Passing Arguments
If you look closely at the __doPostBack function you will notice that the second argument is called the eventArgument. You can allow controls to pass arguments to the doPostBack function. Check out the code below.
Listing 6 – Passing arguments to the __doPostBack function


string passedArgument = Request.Params.Get("__EVENTARGUMENT");
Description
The “Button2” when clicked fires the DoPostBack function which in turn calls the __doPostBack. The __doPostBack function contains two arguments, eventTarget and eventArgument. The eventTarget is “Button2” and the eventArgument is “My Argument.” Later, in the C# code behind, I have accessed the eventArgument using the Request.Params collection. The passedArgument variable will contain the value “My Argument.”
Thanks to aspalliance.com
Posted by Spanco at 2:19 PM
Labels: Javascript

Tuesday, July 19, 2011

Formatting Source Program Code in BlogSpot

Use the <pre> tags for Source Code.

Crystal Reports - various input paramaters

Here is a way to have multiple input parameters specified.
In each of the below scenarios, if no parm is specified for the field, its value is set to true. Otherwise the actual condition is evaluated returning the appropriate true or false. Then all of the parms are "ANDED" together to get whether a record is selected or not.


(
    if {?sDispositions} <> "" then
        {purchaseorders.sDisposition} in {?sDispositions}
    else
        true
)
and
(
    if {?sFrom} = "" then 
       true
    else
       Date({purchaseorders.dtLastUpdate}) >= Date({?sFrom})
)
and
(
    if {?sTo} = "" then 
       true
    else
       Date({purchaseorders.dtLastUpdate}) <= Date({?sTo})
)
and 
(
    if {?sServicers} = 0 then
        true
    else
        {purchaseorders.iServicer} in {?sServicers}
)

Monday, July 11, 2011

Change Datagrid view data alignment

To change the alignment for specific columns in a datagridview, use the following:


dgvSummary.DataSource = dtSum
With dgvSummary.Columns
.Item(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight
.Item(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight
End With

dgvSummary.Refresh()