Adding return values to SubModal#

A while back I blogged about SubModal, a little tool for creating nice modal dialogs on websites.

One of the things I wanted to do was have the modal dialog return a value, like the showModalDialog does in IE.

To achieve this, follow these instructions.

In your "main" html page, declare a callback function and a button that will launch the modal dialog:

    function myFunction(val){
        alert("Return value is...");
        alert(val);
    }

Then create an input button to launch the modal dialog.

<input type="button" onclick="showPopWin('modalcontent.html', 400, 200, myFunction);" />

Then, in the submodalsource file, or where ever you have your JS stored, change this function to include a return value, and have it use it.

/**
 * @argument callReturnFunc - bool - determines if we call the return function specified
 * @argument returnVal - anything - return value 
 */
function hidePopWin(callReturnFunc, returnVal) {
    //alert(callReturnFunc);
    gPopupIsShown = false;
    restoreTabIndexes();
    if (gPopupMask == null) {
        return;
    }
    gPopupMask.style.display = "none";
    gPopupContainer.style.display = "none";
    if (callReturnFunc == true && gReturnFunc != null) {
        // edited by CDM -- gReturnFunc(window.frames["popupFrame"].returnVal);
        gReturnFunc( returnVal );
    }
    gPopFrame.src = gLoading;
    // display all select boxes
    if (gHideSelects == true) {
        displaySelectBoxes();
    }
}

Then finally on your modal page, just some code to close the window, and pass back the return value.

<button onclick="window.parent.hidePopWin(true, 'I am the return value')">close</button>
Categories: Programming | HTML | Javascript
Wednesday, November 29, 2006 4:06:50 PM (Central Standard Time, UTC-06:00) #    Comments [2]  | 

 

Wrapping .Net Unit Tests in Enterprise Services Transactions#

I am already using Enterprise Service Transactions in an app that I wrote to automate the generation of invoices at Walsh.

This same technique is an option (I have probably blogged about it before, but this is a nice article) for rolling back DB changes.

http://weblogs.asp.net/rosherove/articles/dbunittesting.aspx

 

Categories: Programming | Testing
Wednesday, November 29, 2006 4:03:09 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Using TFS Checkin Policy To Force Comments#

I went to a DevCares event today and heard some people talk about TFS.

The topic of Checkin Policies was of spcial interest.  I quickly found this policy that will require that methods be documented.

http://www.codeplex.com/Wiki/View.aspx?ProjectName=TFSCCPolicy

I think this would be a GREAT thing to have in our environment, where comments are very scarce.

Categories: TFS
Monday, November 27, 2006 6:29:03 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Can I please delete a file?#

So now what?

Categories: Funny Stuff
Monday, November 27, 2006 4:10:25 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Changes to "Insert Code" in dasBlog#

I am proposing some updates to dasBlog.  I made some changes that fix some problems with the Insert Code feature, as well as adding a few features ("Left Justify of the code") and the addition of JScript support (I had nothing to do with the XML file changes... those are from the original author.

Here are my changes.

 

Categories: Blogging | dasBlog
Sunday, November 26, 2006 4:29:30 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

DasBlog Patch Submitted#

Yesterday I wrote about the changes I made to dasBlog to solve an outstanding bug in the Insert Code option in the textbox editor.

I added some extra features, like the ability to insert JavaScript (this change was simply the merger of some XML data that the original author has released) and some code that will remove extra white space from the left side of the code block.

I used this article from Scott Hanselman to submit the patch.

Categories: dasBlog
Sunday, November 26, 2006 4:28:33 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Social Networking Links#

Yesterday I added the links you see at the bottom of this article that allow users to quickly submit these articles to your favorite social networking site.

This wasn't as easy as you would think.  I didn't fully understand dasBlog's template system, thinking I could use server side script inside the <% %> brackets.  This is of course not the case.

I ended up finding a partial solution here by Mads Kristensen.

However, I found that this solution failed in a few ways.  First, the URLs being submitted in the querystring were not fully encoded.  The result was that some sites (I verified Digg.com) did not accept these.  It would give you an error that your URL was not correct.  The other problem, was that most of these links include a title, which is good, but they cause JS errors if you have a single quote in your article title.

After some screwing around, I realized that the only way around this problem would be a custom dasblog macro on the server that could encode the titles.

So, I just removed the titles for now.

As an added bonus, this will be an opportunity for me to test out the new JavaScript syntax highlighting I now have on my blog.

<script type="text/javascript">

  var tn = document.createTextNode('<%ItemTitle%>');
  var div = document.createElement('div');
  div.appendChild(tn);
  var html = div.innerHTML;
  var index = html.indexOf('&gt;') +4;
  var title = html.substring(index, html.length - 10);
  var social = '<div style="float:left">';
  social += '<a href="mailto:?body=Thought you might like this: <%permalinkUrl%>&amp;subject=' + title + '" target="_blank" title = "Email This Article">Email it</a>&nbsp;|&nbsp;';
  social += '<a href="http://digg.com/submit?phase=2&url=' + encodeURIComponent('<%permalinkUrl%>') + '" target="_blank"  title = "Post To Digg">Digg it</a>&nbsp;|&nbsp;';
  social += '<a href = "http://del.icio.us/post?url=' + encodeURIComponent('<%permalinkUrl%>') + '&amp;title=' + title + '" target="_blank" title = "Post this article to del.icio.us">Del.icio.us it</a>&nbsp;|&nbsp;';
  social += '<a href = "http://reddit.com/submit?url=' + encodeURIComponent('<%permalinkUrl%>') + '" target="_blank" title = "Post to Reddit">Reddit</a>&nbsp;|&nbsp;';
  social += '<a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;mkt=en-us&amp;url=' + encodeURIComponent('<%permalinkUrl%>') + '&amp;top=1" target="_blank" title = "Post to Live">Live it</a>&nbsp;|&nbsp;';
  social += '<a href="http://www.dzone.com/links/add.html?url=' + encodeURIComponent('<%permalinkUrl%>') + '" target="_blank" title="Post to DZone">DZone it</a>&nbsp;|&nbsp;';
  social += '<a href="http://www.dotnetkicks.com/submit?url=' + encodeURIComponent('<%permalinkUrl%>') + '" target="_blank" title="Post to DotNetKicks">Kick it</a>';
  social += '</div>';
  document.writeln(social);

</script>
Not bad (looks like it got a little confused by the nested strings, but that IS confusing).

Just put this code in your template of choice and you should see good results.
Categories: dasBlog
Sunday, November 26, 2006 4:26:51 PM (Central Standard Time, UTC-06:00) #    Comments [2]  | 

 

DasBlog Recent Comments Macro#
Categories: dasBlog
Sunday, November 26, 2006 4:24:49 PM (Central Standard Time, UTC-06:00) #    Comments [1]  | 

 

DasBlog Custom Macros#

If you want to do anything on the server side with Dasblog, you need to make a custom macro.

This article shows how to do exactly that:

http://blog.krisvandermast.com/CreatingCustomMacrosForDasBlog.aspx

 

Categories: dasBlog
Sunday, November 26, 2006 4:23:30 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Technology Focused VCs#

Here are 2 sites I have been reading:

http://earlystagevc.typepad.com/earlystagevc/

and this article of AskSlashdot:

http://interviews.slashdot.org/article.pl?sid=06/10/13/1451242&from=rss

It's interesting to learn about how people are building these applications and businesses.

Categories:
Sunday, November 26, 2006 4:20:48 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

10 Rules For Web Startups#

Interesting list for 10 rules web startups should follow:

http://www.evhead.com/2005/11/ten-rules-for-web-startups.asp

 

Categories: Interesting
Thursday, November 23, 2006 9:42:59 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

.Net Search Engine#

Lucene.Net is another document index search engine.

You can point it at some files, office, pdf, rtf, html, and it will index them and provide a nice google-like results page.

http://dotlucene.net/

Categories: Programming | .Net | ASP.Net
Thursday, November 23, 2006 9:21:13 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

The top 10 mistakes when using AJAX#

Here is an interesting list of the top 10 things people do wrong when using AJAX.

http://weblogs.asp.net/mschwarz/archive/2006/11/20/the-top-10-mistakes-when-using-ajax.aspx

  1. Don't use AJAX to update the complete page by putting everything in a UpdatePanel. You want to save time and traffic when running the web page. Never update parts of the web site that can be changed using JavaScript and DHTML (DOM).
  2. Have in mind that there are a couple of visitors that have JavaScript disabled or using a web browser with an older or less JavaScript implementation like the most mobile devices have. What does your visitor see if everything is disabled? I don't recommend to have the full web site available as a JavaScript disabled version!
  3. Cache the same requests on client-side web browser or implement any caching on the web server. The most used scenarios like AutoComplete or DropDown fields are filled everytime the same. A wrong written AutoComplete can slow down your web server (database server) because there more requests done than the version before using PostBacks. Think of pressing F5 (reload) all the time with your old web site. If you have cascading DropDown you can save more traffic/requests!
  4. Don't run concurrent or long running AJAX requests when using CSS or JavaScript to change the UI. There are only two concurrent http connections possible with all common web browsers (I know you can change this, but the default behavior is set to two). If there are running to many AJAX requests running loading of images will be slow down.
  5. Use everytime the asynchrouns invoke of the send method of XMLHttpRequest. There is no issue where you want to use the synchronous one. Your web browser will not be forozen when having network problems or slow connections.
  6. Try your web application using a very slow internet connection. Try it again using a TCP/IP connection with a very high latency for each paket.
  7. Is your web application running as a desktop replacement? Have a look at the memory usage of common web browsers if you run your application one hour, two hours or couple of days. Not everybody has a development machine like yours!
  8. Check the http status code you will get back from XMLHttpRequest. There are a couple of common network errors like DNS not available, http server error 500. Did you ever checked for the status code which tells you if your web browser is in offline mode?
  9. Try to disable the XMLHttpRequest object! With IE7 you can use the native object instead of the ActiveX object, but you can still disable the native object, too.
  10. Check your AJAX requests for security issues! Did you simple open all your data access layers? Make use of FormsAuthentication and PrincipalPermissions on ASP.NET. Can anybody create requests (not only by clicking on a link)?
Categories: Programming | AJAX | HTML | Javascript
Thursday, November 23, 2006 9:19:08 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Some cool sorting visualizations#

Here are too cool pages that show visual representations of different sorting algorithms.

http://www.cs.rit.edu/~atk/Java/Sorting/sorting.html

http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html

Categories: Programming
Thursday, November 16, 2006 9:57:54 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Copying SQL Server Results With Column Headers#

I just came across this nice tip:

One change with SQL Server 2005 is a new option to copy column headers along with the data results.  This option gets set using the query options setting.  To access this setting from SQL Server Management Studio, select Query | Query Options from the menus

You can then paste the columns into excel and you will get the headers as well.

http://www.mssqltips.com/tip.asp?tip=1107

 

Categories: SQL Server
Tuesday, November 14, 2006 2:51:13 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Client Side Modal Dialogs (SubModal)#

One thing that I really like about IE, but is not available in other browsers is the client side modal dialog.

A modal dialog is a popup window that must be acted on (or closed) before you can do anything else on the window underneath.

I came across a nice modal dialog being used on the forums.asp.net site.  I ended up emailing the guy who wrote the editor I was using, and he directed me to the original creator of the dialog "submodal."

Some people have made updates and extensions to submodal, and there has been a google group created for the discussion of submodal.

It is still not clear to me if this technique will allow you to pass back a value from the modal dialog to the opening page, because I think that is a very important feature, but I don't see any direct reference to it.

Categories: Programming | Javascript
Monday, November 13, 2006 4:31:21 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Dealing with WinForms Combobox and name/value items.#

I just read this article on aspalliance.com by Sandeep Archarya.

I think the article had 2 main points.  One was that databinding a combobox is not "bug free" because the act of manually databinding to a combobox causes the SelectedIndexChanged event to fire.  The second point was to show how to create a simple namevalue class to be added to the combobox items collection to get around the "problem" of combobox's taking an object as the item in it's list (as opposed to a name value pair).

I would point out the following:

First, I am not sure that I would call the SelectedIndexChanged event firing a bug.  When you manually databind a list, the first item become selected by default, and thus the selectedindex HAS changed, from -1 to 0.

Second, if you consider this a problem you can get around it a couple different ways.

1) Don't use manual databinding.

In the designer, select a datasource or create a new one.  I created a simple employee object and created an object datasource for this employee.  This creates a EmployeeBindingSource object that I bind my employee list to.  Using this method, I didn't experience the SelectedIndexChanged event firing on the databind.

Private list As New System.Collections.Generic.List(Of employee)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    '*** create some fake employee objects
   For i As Integer = 70 To 80
      list.Add(New employee(i, Chr(i)))
   Next

    '*** this will populate our control (Combobox1)
   Me.EmployeeBindingSource.DataSource = list

End Sub

2) You can use manual databinding, and manually detach and attach the event handler for this event.

Private list As New System.Collections.Generic.List(Of employee)

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
    '*** create some fake employee objects
   For i As Integer = 70 To 80
      list.Add(New employee(i, Chr(i)))
   Next

    '*** remove the handler
    RemoveHandler ComboBox1.SelectedIndexChanged, AddressOf ComboBox1_SelectedIndexChanged
    '*** databind
    Me.ComboBox1.ValueMember = "id"
    Me.ComboBox1.DisplayMember = "name"
    Me.ComboBox1.DataSource = list
    '*** add the handler back
    AddHandler ComboBox1.SelectedIndexChanged, AddressOf ComboBox1_SelectedIndexChanged
End Sub

 

Categories: .Net | .Net Framework | DataBinding | WinForms
Friday, November 10, 2006 4:32:43 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

.Net 3.0 Free Online Labs From Microsoft#

Microsoft is offering some free online lab training on .Net 3.0 for a limited time.

Use this link: http://msdn.microsoft.com/virtuallabs/netframe/default.aspx

Categories: Programming | .Net
Monday, November 06, 2006 4:37:39 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

VS.Net for Database Launch Event#

Microsoft is releasing "Visual Studio Team Edition 2005 for Database Professionals" (who on Earth comes up with these names????).

MS is holding some launch events all over where you can come (for free) and learn a little about this product, which from what I saw looks pretty slick.

http://www.teams-deliver.com

Categories: .Net | VS.Net | SQL Server
Monday, November 06, 2006 4:36:25 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Red Gate SQL Refactor Tool Looks Cool#

Red Gate has a pretty interesting tool called SQL Refactor:

http://www.red-gate.com/products/sql_refactor/index.htm

 

The "Layout Code" feature looks awesome.  It basically takes a terrible looking select statement and turns it into a nicely formatted block.

 

Here is a code project article that shows some of these features:

http://www.codeproject.com/showcase/SQLRefactor.asp

 

Categories: SQL Server
Monday, November 06, 2006 4:34:42 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Convert RTF to HTML#

More than once I have looked into a way to convert RTF into HTML.  Mostly because there are RTF textboxes available for winforms, but you might want to save the page as HTML, and not RTF.

This article shows a way to do this that:

http://www.codeproject.com/vb/net/RTFToHTML.asp

Categories: Programming | .Net | .Net Framework
Monday, November 06, 2006 4:33:56 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Missing Step in, Step Out and Macros in VS.Net#

A while back I had some problems with a coworkers VS.net settings.

They were missing the step in and step out as well as the Macros option in the tools menu.

We were able to get these back by changing the VS.Net settings by going to Tools->Import and Export settings.

Then select to Import settings and pick where you want to backup your current settings.

Then I think we picked "Visual Basic Development Settings" or maybe "General Development Settings."  This seemed to get things back to normal for the most part.

I still have a few problems, like if I am working on some file, that file will not be highlighted in the solution explorer (what a pain) and I can't right click on a webform and select "View Code" (what a pain).

It looks like MS was trying to make it really customizable, but I think they ended up making it a pain to get things working the way you expect them to.

 

UPDATE:
I was able to quickly find a setting to make sure that the current page I was working on became tracked in Solution Explorer:

 

Categories: Programming | .Net | VS.Net
Wednesday, November 01, 2006 4:38:40 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

All content © 2010, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.9074.18820

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: