Page A has an iframe that loads Page B in it.
<div style="display:block; height:0px; width:0px;">
<iframe id="frame1" height="0" width="0"></iframe>
</div>
<asp:HiddenField runat="server" id="IsFileGenerated" Value="False"/>
Javascript
$(function () {
frame1.src = [Page B];}
On page B a file is downloaded (on pageLoad) after which i want to set the hiddenField value on Page A..Is it possible?
page A has a button on whose click i need to check if the file is downloaded..
OK, as soon as I post a question, it hits me !
Here is what I did
Page A
<div style="display:none"><label id="IsFileGenerated">False</label></div>
JS - On button click
if ($('#IsFileGenerated').text() == "True") {//do something}
Page B
function OnFileDownloaded(data) {
parent.document.getElementById("IsFileGenerated").innerHTML = "True";
}
Related
I have a dynamically named DIV in a GridView which contains a user control with a dynamically assigned Parent_ID. The javascript is used to show or hide the DIV. I'll show you two examples of different rows without the ASP code.
Row 1 showing for Order # 123456:
<a href="<%#"javascript:collapseExpand('Order_Notes_Panel123456');" %>" >+</a>
<div id='Order_Notes_Panel123456' style="display:none;">
<uc:Comments_Control id="Comments_Control_ID" runat="server" Parent_ID='123456'/>
</div>
Row 2 showing for Order # 678901:
<a href="<%#"javascript:collapseExpand('Order_Notes_Panel678901');" %>" >+</a>
<div id='Order_Notes_Panel678901' style="display:none;">
<uc:Comments_Control id="Comments_Control_ID" runat="server" Parent_ID='678901'/>
</div>
The good news is that the user control binds and works perfectly. The javascript shows (sets the style to "display:block;") and hides (style set to "display:none;") the appropriate DIV each time the '+' is clicked.
Here is my problem: there is a 'Reply' link in the user control that, when clicked, does a post-back and puts the control into Edit mode. When I employ this user control on another page without a containing DIV, you won't notice a thing. However, when the 'Reply' does its post-back, the containing DIV reverts back to style="display:none;".
Can you provide a recommendation how to set the parent DIV's style to "display:block;" while a user is obviously working with it? I would imagine the appropriate code would go in the code behind of the user control when it goes into Edit mode.
Thanks,
Rob
Update: I recognize that there is no runat=server in my DIV. Since I'm trying to establish a dynamic ID for each, I get an error if I try to use the runat. That is probably the reason why I can't reach it from code behind...
I am very happy of myself... (see the YouTube video for this phrase, you'll be glad you did.)
In summary, this is what I added:
1. New Javascript function to add the name of the target DIV to a hidden field (The "collapseExpand" function is in the Site.Master. I couldn't put "load_div_to_hidden" in the Site.Master since "myhiddenField" isn't set up on every page
2. New hidden field to capture the name of the target DIV
3. New Javascript function to run on window.onload, check if we've got a post-back, and then display the value from the hidden field
4. Adding second Javascript call from the href in the link
Below are the new snippets of code:
<script type="text/javascript">
function load_div_to_hidden(obj) {
var hidden = document.getElementById('<%= myhiddenField.ClientID %>');
hidden.value = obj;
}
function windowOnLoad() {
var isPostBack = (('<%= IsPostBack %>').toLowerCase() == 'true') ? true : false;
if (isPostBack == true) {
var hid_field_value = document.getElementById('<%= myhiddenField.ClientID %>').value;
var right_div = document.getElementById(hid_field_value);
right_div.style.display = "block";
}
}
window.onload = windowOnLoad;
</script>
<input type="hidden" id="myhiddenField" runat="server" value="" />
<a href="<%#"javascript:collapseExpand('Order_Notes_Panel123456'); javascript:load_div_to_hidden('Order_Notes_Panel123456');" %>" >+</a>
<div id='Order_Notes_Panel123456' style="display:none;">
<uc:Comments_Control id="Comments_Control_ID" runat="server" Parent_ID='123456'/>
</div>
Works like a charm!
I am a desktop client developer. I now got to continue this project is ASP.NET with AJAX, so I am learning web development the hard way.
I need to get a list of all check boxes and their states from repeater control on Summary.aspx when user clicks button CmdSave on ChoicePage.aspx.
Can I subscribe to event CmdSave_Click() in Summary.aspx or is there some way to approach Summary.aspx's repeater control from ChoicePage.aspx?
(MSDN talks about passing values from page to page in this article but this doesn't help me)
Here is the problem:
Page ChoicePage.aspx is included in Master AppMaster.master page. ChoicePage has Content tag which includes CmdSave and it's event handler CmdSave_Click() and it also includes iframe tag for displaying another page, Summary.aspx
On Summary.aspx I have repeater control which is bound to DataSource and relevant fields are of type bool represented by column of editable check boxes. Clicking these checkboxes mustn't cause Summary.aspx to refresh so I am not looking to handle (server-side) CheckedChanged event.
I am not sure if any code example would help here since this is more a concept question
function SetFrameStatus() {
var v = hdCommand.value.toString().toLowerCase();
hdCommand.value = "";
var frms = (GetFrameAll("FrameSummary"));
if (frms)
{ }
else return;
FrameSummary = frms[0];
DivSummary = FrameSummary.parentNode;
var FrameWindow = frms[1];
var FrameDocument = frms[2];
if (v == "showsummary") {
FrameWindow.location.replace(SummaryPageName);
}
}
<asp:Content ID="ContentSummary" ContentPlaceHolderID="NoUpdateDiv" runat="server">
<div id="DivMenu" class="Flat" style="overflow:visible; display:none;position:absolute;">
<input type="button" id="CmdSave" value="Save" onclick="CmdSave_Click()" />
</div>
<div id="DivSummary" style="position:absolute;margin:0px;padding:0px;display:none">
<iframe title="Loading" id="FrameSummary" marginheight="0px" marginwidth="0px" scrolling="auto"
style="padding:0px; margin:0px;width:auto;" src="loading.htm?Redirect=Summary.aspx" frameborder="0"
onload="FrameSummary_Load()"
></iframe>
</div>
In the end this is what solved my problem:
On ChoicePage.aspx in CmdSave_Click() function I called another function on Summary.aspx.
This other function did __dopostback("Repeater", "") and on Render event in my code behind I iterate through a Repeater.
I am leaving this question unanswered because I am sure there is a better way to do this.
I'm looking for a solution to my problem for two days and I didn't find anything that can help. I have two page : page 1 and page 2
Page1 contains parameters that will be send to page2 and a button "Create"
Page2 contains the GridView and on page_load I have
GetParameters() ; // extract parameters
PrepareParameters(); // prepare local variable
DataTable dt = CreateDataTable(); // create the BoundField/Columns based on prepared local variables
myGridView.DataSource = dt;
myGridView.DataBind();
My problem is that the method PrepareParameters() takes time due to the huge amount of data even though it's optimized. When I click on "Create" button the browser doesn't move to page2 but instead it doesn't respond and stay in page1 and the user does not know what happens.
So I'm wondering how to redirect the browser to page2 and show to the user a loading animation on the grid place until the PrepareParameters() finish processing data and display the GridView once finished?
Thanks for your reply.
You can use Javascript to do that. Get any loader image you prefer, there are many available on net, google it
put this image top/bottom of grid, assign some id to it and set default property Visible = false.
Now on button click call javascript where you make this image visible.
Sample code
<html>
<head>
<script type="text/javascript" language="JavaScript">
function Loading() {
document.getelemanebyId('Img').visibility = visible;
}
</script>
</head>
<body>
<form action="" method="POST" id="myForm">
//Gridview control here
<img id="Img" src="give image file path" runat="server" visible="false"/>
<button name="Create" onClientClick="Loading();" runat="server" >
</form>
</body>
</html>
I am new to ASP.NET and C# and have one doubt.
I have one link button in master page and I have one modalpopupextender in my content page.
I need When I click that button the modal popup window will open in the content page..
Can anyone help, it's very useful for me?
Thank you
Javascript and markup on the master page:
function showClientPopUp() {
var extender = $get("popupExtenderBehaviorID");
if (extender !== null) {
extender.show();
}
}
<asp:LinkButton runat="server" OnClientClick="showClientPopUp(); return false;" Text="Show PopUp"/>
Work on ASP.NET Visual Studio 2008 C#. I have a page. From this page I need to call a page on popup. On the popup page selected value will be set on the parent page text control.
One parent page
One child page.
Call parent to child as popup.
On popup window contain a grid.
On popup grid have command select,click on select close popup and selected value will set on parent page text control.
I have done steps 1,2,3 and 4. But I need to complete step no 5.
On parent page:
<script type="text/javascript">
function f1() {
window.open("child.aspx");
}
</script>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><input type="button" onclick="f1();" value="pop up" />
On child page:
<script type="text/javascript">
function f2() {
opener.document.getElementById("TextBox1").value = "hello world";
}
</script>
<input type="button" value="return hello world" onclick="f2();" />
Also you can pass ID of control which you want fill from child page as GET parameter:
window.open("child.aspx?controlID=<%=TextBox1.ClientID %>");