Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:15:59+00:00 2026-06-13T03:15:59+00:00

I am new to ASP.NET and JQuery. Currently, I have the codes for JQuery

  • 0

I am new to ASP.NET and JQuery.

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.

I have these two buttons:

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

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

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

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

These the Labels (in the DetailsView) where the JQuery use for passing the parameters.

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

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?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:16:01+00:00Added an answer on June 13, 2026 at 3:16 am

    Try something like this:

    function OpenIframe(url, recordId, width, height, event)
    {
        if(event.preventDefault)
            event.preventDefault(); 
        else
            event.returnValue = false;
    
        var page = url + "?" + recordId + "="+ encodeURIComponent($('span[id$="' + recordId + '"]').text());
        var pagetitle = $(this).attr("title"); 
        var $dialog = $('<div></div>') 
        .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"  frameBorder="0"  align="middle"> ></iframe>') 
        .dialog({ 
            autoOpen: false, 
            modal: true, 
            height: height | 650 , 
            width: width | 900, 
            title: pagetitle 
        }); 
        $dialog.dialog('open');
    }
    

    Your aspx would look like this:

    <table width="80%" align="center" >
         <tr>
            <td width="45%"></td>
            <td width="10%" class="PageTitle"></td>
            <td width="45%" style="text-align:right;">
                <input type="button" onclick="OpenIframe('<%= ResolveClientUrl("ProposalCreateNote.aspx")%>', 'ProposalID', 900, 650, event); return false;" value="Create Approved MDF" title="Create Approved MDF" class="button3" />
                <input type="button" onclick="OpenIframe('<%= ResolveClientUrl("ApprovedCreateNew.aspx")%>', 'AnotherID', 900, 650, event); return false;" value="Create Note" title="Create Note" class="button3" />
            </td>
        </tr>
    </table> 
    

    Didn’t use asp.net button markup because you would have to define it as runat=”server” and you wouldn’t be able to put escape characters on the OnClientClick event call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the new Bundling feature in ASP.NET MVC4. Currently I have the following
Im currently new to PHP and JQuery after having using ASP.Net and C Sharp
I am new to ASP.net & Jquery.I am trying to implement autocomplete in my
I am a new ASP.NET developer and I am developing a web-based suggestions box
I have a new asp.net mvc project and i am trying to figure out
I am new ASP.NET and I have never used a GridView or DataGrid, but
My website currently working in ASP.NET 1.1 Old Process In our database we have
Environment used: ASP.NET, jQuery I have the following AJAX call: var tempVar = JSON.stringify({plotID:currentId});
I am very new to ASP.NET 4 and MVC 4. I have a requirement
I am currently looking a valiadation controls in javascript and ASP.NET and have come

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.