asp.net datasource control parameter outside iframe -
hope can me here, have been searching solution few days havent't found it.
i have build page 2 iframes, selectcustomer opens page in dropdownlist lives customer names , iframecontent in load page clicking link. page has sqldatasource parameter. want refer dropdownlist in parameter filter select query haven't found way refer dropdownlist outside iframe "iframecontent".
this page iframes:
<%@ page title="" language="vb" masterpagefile="~/dashboard/sales/dashboard_sales.master" autoeventwireup="false" codefile="index.aspx.vb" inherits="dashboard_sales_default" %> <asp:content id="content1" contentplaceholderid="head" runat="server"> </asp:content> <asp:content id="content2" contentplaceholderid="maincontent" runat="server"> <!doctype html> <html> <head> </head> <body> <iframe name="selectcustomer" src="selectdebiteur.aspx" align="top" frameborder="0" height="50" width="100%" marginheight="0" marginwidth="0" scrolling="auto"> </iframe> <iframe name="iframecontent" height="500" width="100%"> </iframe> </body> </html> </asp:content> this page first iframe:
<%@ page language="vb" autoeventwireup="false" codefile="selectdebiteur.aspx.vb" inherits="dashboard_sales_selectdebiteur" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#dropdownlist1").on("change", function () { // when dropdownlist selected value has been changed, // refresh other iframed page changing source // adding value query string. $("#iframecontent", parent.document).attr("src", "default.aspx?value=" + $(this).val()); return true; }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <asp:sqldatasource id="listdebiteur" runat="server" connectionstring="<%$ connectionstrings:flosconnectionstring2 %>" selectcommand="select [aa-270].cddeb, [ba-001].naamorg debiteur [aa-270] inner join [ba-001] on [aa-270].cdorg = [ba-001].cdorg order debiteur"></asp:sqldatasource> <asp:dropdownlist id="dropdownlist1" runat="server" autopostback="true" datasourceid="listdebiteur" datatextfield="debiteur" datavaluefield="cddeb"> </asp:dropdownlist> </div> </form> </body> </html> this page get's loaded in second iframe:
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:sqldatasource id="listcustomers" runat="server" connectionstring="<%$ connectionstrings:flosconnectionstring2 %>" selectcommand="select [aa-270].cddeb, [ba-001].naamorg debiteur [aa-270] inner join [ba-001] on [aa-270].cdorg = [ba-001].cdorg order debiteur"></asp:sqldatasource> <asp:dropdownlist id="dropdownlist2" runat="server" autopostback="true" datasourceid="listcustomers" datatextfield="debiteur" datavaluefield="cddeb"> </asp:dropdownlist> <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:flosconnectionstring2 %>" selectcommand="select [va-211].cdorg, [ba-001].naamorg, rtrim(year([va-211].[datum-lvoor])) + '-' + case when rtrim(month([va-211].[datum-lvoor])) < 10 '0' + rtrim(month([va-211].[datum-lvoor])) else rtrim(month([va-211].[datum-lvoor])) end maand, sum(case when [va-211].cdstatus = 'o' [va-211].aanttelev * ([va-211].prijs / [bb-063].prijsper) when [va-211].cdstatus = 'a' [va-211].aantgelev * ([va-211].prijs / [bb-063].prijsper) end) omzet [ba-001] inner join [va-211] on [ba-001].cdorg = [va-211].cddeb left outer join [bb-063] on [va-211].cdprodukt = [bb-063].cdprodukt ([bb-063].cdprijssrt = 'verk') , ([va-211].cdstatus = 'o' or [va-211].cdstatus = 'a') group [ba-001].naamorg, rtrim(year([va-211].[datum-lvoor])) + '-' + case when rtrim(month([va-211].[datum-lvoor])) < 10 '0' + rtrim(month([va-211].[datum-lvoor])) else rtrim(month([va-211].[datum-lvoor])) end, [va-211].cdorg having (sum(case when [va-211].cdstatus = 'o' [va-211].aanttelev * ([va-211].prijs / [bb-063].prijsper) when [va-211].cdstatus = 'a' [va-211].aantgelev * ([va-211].prijs / [bb-063].prijsper) end) > 0) , ([va-211].cdorg = @param1) order maand, [ba-001].naamorg"> <selectparameters> <asp:controlparameter controlid="dropdownlist2" name="param1" propertyname="text" defaultvalue="00000739" /> </selectparameters> </asp:sqldatasource> <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" cellpadding="4" datasourceid="sqldatasource1" enablemodelvalidation="true" forecolor="#333333" gridlines="none"> <alternatingrowstyle backcolor="white" /> <columns> <asp:boundfield datafield="cdorg" headertext="cdorg" sortexpression="cdorg" /> <asp:boundfield datafield="naamorg" headertext="naamorg" sortexpression="naamorg" /> <asp:boundfield datafield="maand" headertext="maand" readonly="true" sortexpression="maand" /> <asp:boundfield datafield="omzet" headertext="omzet" readonly="true" sortexpression="omzet" /> </columns> <editrowstyle backcolor="#7c6f57" /> <footerstyle backcolor="#1c5e55" font-bold="true" forecolor="white" /> <headerstyle backcolor="#1c5e55" font-bold="true" forecolor="white" /> <pagerstyle backcolor="#666666" forecolor="white" horizontalalign="center" /> <rowstyle backcolor="#e3eaeb" /> <selectedrowstyle backcolor="#c5bbaf" font-bold="true" forecolor="#333333" /> </asp:gridview> </div> </form> </body> </html> and it's code behind page:
using system; using system.collections.generic; using system.web; using system.web.ui; using system.web.ui.webcontrols; public partial class dashboard_sales_default : system.web.ui.page { protected void page_load(object sender, eventargs e) { if (!page.ispostback) dropdownlist2.selectedvalue = request.querystring["value"]; } } new challenge:
<a href="javascript:openpage()" target="iframecontent">omzet in portefeuille </a> </li> <scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> openpage = $(function () { location.href = "default.aspx?value=" + $("#dropdownlist1").val(); }); </script>
one of solutions refresh second iframed page sending dropdownlist selected value query string, using jquery (to make things easier).
to demonstrate, i'm updating dropdownlist on second iframed page, can adapt needs:
main page (where iframes placed):
<iframe id="iframe1" width="500" height="200" src="webform1.aspx"></iframe> <iframe id="iframe2" width="500" height="200" src="webform2.aspx"></iframe> first iframed page:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#ddl1").on("change", function () { // when dropdownlist selected value has been changed, // refresh other iframed page changing source // adding value query string. $("#iframe2", parent.document).attr("src", "webform2.aspx?value=" + $(this).val()); return true; }); }); </script> <asp:dropdownlist id="ddl1" runat="server" autopostback="true"> <asp:listitem text="option 1" value="1"></asp:listitem> <asp:listitem text="option 2" value="2"></asp:listitem> </asp:dropdownlist> second iframed page:
<asp:dropdownlist id="ddl2" runat="server" autopostback="true"> <asp:listitem text="option 1" value="1"></asp:listitem> <asp:listitem text="option 2" value="2"></asp:listitem> </asp:dropdownlist> protected void page_load(object sender, eventargs e) { if (!page.ispostback) ddl2.selectedvalue = request.querystring["value"]; } update
regarding question posted on comments, can find out what's second page iframe's src (and subsequently change it) way:
$("#iframe2", parent.document).attr("src", $("#iframe2", parent.document).attr("src") + "?value=" + $(this).val()); update #2
as per request, want load iframe source dynamically, @ page load. that's how can achieve this:
main page (where iframes placed):
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#iframe2").attr("src", "the-page-you-want-to-load-on-this-iframe"); }); </script> <iframe id="iframe1" width="500" height="200" src="webform1.aspx"></iframe> <iframe id="iframe2" width="500" height="200"></iframe> first iframed page:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#ddl1").on("change", function () { var iframe2basesrc = $("#iframe2", parent.document).attr("src"); if (iframe2basesrc) { iframe2basesrc = iframe2basesrc.split("?")[0]; $("#iframe2", parent.document).attr("src", iframe2basesrc + "?value=" + $(this).val()); } return true; }); }); </script>
Comments
Post a Comment