ASP.NET Jquery functions combine into one, if possible
<p>I am new to ASP.NET and JQuery.</p>

<p>Currently, I have the codes for JQuery to load two different pages and passing value based on two different buttons click (controling by button ID). It seems like I am duplicating the codes, so I wonder if I can make this some sort like javascript function to pass 4 parameters (Page or URL, RecordID, width, height). Lets me explain with the codes.</p>

<p>I have these two buttons:</p>

<pre><code>&lt;table width="80%" align="center" &gt;
    &lt;tr&gt;
        &lt;td width="45%"&gt;&lt;/td&gt;
        &lt;td width="10%" class="PageTitle"&gt;&lt;/td&gt;
        &lt;td width="45%" style="text-align:right;"&gt;
            &lt;asp:Button runat="server" CommandName="buttonCreateApprovedMDF" ID="buttonCreateApprovedMDF" 
            Text="Create Approved MDF" href="ApprovedCreateNew.aspx?AnotherID=" title="Create Approved MDF" class="button3"/&gt;  
            &lt;asp:Button runat="server" CommandName="buttonCreateNote" ID="buttonCreateNote" 
            Text="Create Note" href="ProposalCreateNote.aspx?ProposalID=" title="Create Note" class="button3"/&gt;           
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt; 
</code></pre>

<p>And this is the JQuery codes (duplicated), just the Page and RecordID are different, everything is the same.</p>

<pre><code>$(document).ready(function () {  
    $('#&lt;%= buttonCreateNote.ClientID %&gt;').live('click', function(e) { 
    e.preventDefault(); 
    var lblID = $("[ID$='ProposalID']").text();
    var page = '&lt;%= ResolveClientUrl("ProposalCreateNote.aspx")%&gt;' + '?ProposalID=' + encodeURIComponent($('span[id$="ProposalID"]').text());
    var pagetitle = $(this).attr("title"); 
    //alert(page); 
    var $dialog = $('&lt;div&gt;&lt;/div&gt;') 
    .html('&lt;iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"  frameBorder="0"  align="middle"&gt; &gt;&lt;/iframe&gt;') 
    .dialog({ 
        autoOpen: false, 
        modal: true, 
        height: 650, 
        width: 900, 
        title: pagetitle 
    }); 
    $dialog.dialog('open'); 
    });

    $('#&lt;%= buttonCreateApprovedMDF.ClientID %&gt;').live('click', function (e) {
        e.preventDefault();
        var lblID = $("[ID$='AnotherID']").text();
        var page = '&lt;%= ResolveClientUrl("ApprovedCreateNew.aspx")%&gt;' + '?AnotherID=' + encodeURIComponent($('span[id$="AnotherID"]').text());
    var pagetitle = $(this).attr("title");
        //alert(page); 
    var $dialog = $('&lt;div&gt;&lt;/div&gt;')
    .html('&lt;iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"  frameBorder="0"  align="middle"&gt; &gt;&lt;/iframe&gt;')
    .dialog({
        autoOpen: false,
        modal: true,
        height: 650,
        width: 900,
        title: pagetitle
    });
    $dialog.dialog('open');
    });
}); 
</code></pre>

<p>These the Labels (in the DetailsView) where the JQuery use for passing the parameters.</p>

<pre><code>&lt;asp:Label ID="ProposalID" runat="Server" style="text-align:left;" 
Text='&lt;%# Eval("ProposedID")%&gt;' /&gt;
&lt;asp:Label ID="AnotherID" runat="Server" style="text-align:left;" 
Text='&lt;%# Eval("AnotherID")%&gt;' /&gt;
</code></pre>

<p>How can I combine the duplicated JQuery above into one function like "OpenIframe(URL, RecordID, Width, Height)"? and possibly using OnClientClick (with those parameters) to trigger IFrame popup?</p>

<p>Thanks in advance.</p>
