Unable to fetch Cookie values while using Ajax Modal Popup extender - c#

Here's the scenario:
I've a page(Homepage.aspx) which has a button.
When clicked i used to Pass some values in cookies inside _Click method of the button in .CS file and then open a different aspx page(Detail_Report.aspx) where i was retrieving the values from the cookies and then display the content of the page which uses the values i've retrieved.
Now recently i've decided to implement Ajax pop-up extender to show the Detail_Report.aspx page.
I'm able to do this using the following code:
<asp:modalpopupextender id="ModalPopupExtender1"
runat="server" cancelcontrolid="btnCancel"
okcontrolid="btnOkay" targetcontrolid="Detail_Report"
popupcontrolid="DR" popupdraghandlecontrolid="PopupHeader"
drag="true" backgroundcssclass="ModalPopupBG">
</asp:modalpopupextender>
<div class="popupConfirmation" id="DR" style="display: none">
<iframe id="frameeditexpanse" src="DetailReport.aspx" frameborder="1">
</iframe>
<div class="popup_Buttons" style="display: none">
<input id="btnOkay" type="button" value="Done2" />
<input id="btnCancel" type="button" value="Cancel2" />
</div>
</div>
Here's the button declaration:
<asp:Button ID="Detail_Report" runat="server"
style="z-index: 1; left: 60px; top: 110px; position: absolute; width: 230px;"
Text="Detail Report" Font-Bold="True" BorderStyle="Solid"
Enabled="False" onclick="Detail_Report_Click"/>
And this is what i've inside my onClick Method:
protected void Detail_Report_Click(object sender, EventArgs e)
{
//string javaScript = "<script language=JavaScript>\n" + "DetailReport();\n" + "</script>";
Response.Cookies["proj"].Value = c_ProjName.Text.ToString();
Response.Cookies["LOB"].Value = c_LOB.Text.ToString();
Response.Cookies["release"].Value = c_ReleaseName1.Text.ToString();
Response.Cookies["country"].Value = c_CountryName.Text.ToString();
Response.Cookies["testenvkey"].Value = testenvkey.ToString();
//ClientScript.RegisterStartupScript(this.GetType(), "Detail_Report_Click", javaScript);
Now my problem is Pop-up is coming up, but i'm unable to fetch the values from cookies as those are blank. As a result My Detail_Report.aspx page is not displaying correctly

%If Session("ChildLoad") = "True" Then%>
'Model Extender and panel
<%end if%>
and then on the load of child page check the session status if its true then pick the values from session or cookies but to do that you need to enable post back on your main page.
Idea behind is
when you refresh the main page it will fire the load event from child page as well.

Related

close iframe from another page after submit code behind

I have an a web application which have a button that will open an iframe form windows.
open.aspx is the button click
supervisor.aspx is the page open using iframe
the open.aspx
<div style="vertical-align: middle; text-align: center; left: 500px; width: 122px; position: absolute; top: 560px; height: 50px; z-index: 126; right: 889px; font-size: 50pt; font-family: Calibri; font-weight: bold;" id="uncheckbutton">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="UNCHECK" />
//this is the onclick button to open the iframe
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" TargetControlID="Button1"
CancelControlID="Button2" BackgroundCssClass="Background">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panl1" runat="server" CssClass="Popup" align="center" style = "display:none">
<iframe style=" width:400px; height: 150px;" id="irm1" src="Uncheck popup.aspx" runat="server"> </iframe>
<asp:button Top="100px" id="button2" runat="server" text="CLOSE" />
</asp:Panel>
and this is the supervisor.aspx(the iframe)
<asp:TextBox ID="inputid" runat="server" Font-Size="14px" ></asp:TextBox>
<asp:Button ID="Button3" runat="server" Text="Uncheck" OnClick="btnCheck_Click" />
if the user enter the correct username, i want the iframe to automatically close.
this is my supervisor.aspx.cs
protected void btnCheck_Click(object sender,EventArgs e)
{
string uncheck = inputid.Text;
bool supervisor = Cls.GetUncheckSupervisor(uncheck);
if (supervisor==true)
{
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "window.close()",
.true);
}
else
{
Show("Wrong ID!");
}
if the supervisor is true, how can I automatically closed the iframe? for now I use a button click to close and I want to avoid less clicking.
I have try using javascript but the iframe still won't close although the function works.
I following this link How to close window after iframe form submits and also Close iFrame from another webpage + asp.net
thanks
I got guide from Yongqing Yu ( https://forums.asp.net/members/Yongqing%20Yu.aspx ) from asp.net that suggest me to create a js method on the iframe page, call the parent layer of the iframe page, then hide the ModalPopupExtender control and panel control.
Here is the thread
https://forums.asp.net/p/2162174/6287081.aspx?Re+Close+iframe+from+another+page+in+code+behind

Adding Non-Standard Attribute to asp:LinkButton inside Repeater prevents the run of OnItemCommand

I am integrating a Foundation 5 Reveal Modal component with an <asp:LinkButton>. For the reveal modal to work it requires the addition of a non-standard HTML attribute data-reveal-id to the <asp:LinkButton>. If I do 'not' add this attribute in the .aspx below, then clicking the LinkButton will trigger rptNotice_ItemCommand. However, when data-reveal-id is added to the LinkButton as shown below rptNotice_ItemCommand does not run, and lbMessage is not updated. The lbMessage is required by the database upon submission of the modal form.
How do I get this to work?
Is there another way to keep track of the message ID?
In the .aspx file
<!-- Foundation 5 Reveal Modal -->
<div id="replyModal" class="reveal-modal" data-reveal>
<h2>Reply to Notice</h2>
<asp:Label ID="lbMessage" runat="server" />
<asp:TextBox ID='tbFollowQuestion' runat="server" TextMode="MultiLine" Width="100%" /><br />
<asp:Button ID="btnFollowCancel" runat="server" Text="Cancel" OnClick="followQuestionCancel_Clicked" />
<asp:Button ID="btnFollowQuestion" runat="server" Text="Submit" OnClick="followQuestionSave_Clicked" />
<a class="close-reveal-modal">×</a>
</div>
<asp:Repeater ID="rptNotice" runat="server" OnItemCommand="rptNotice_ItemCommand">
<ItemTemplate>
<div class="row padding-bottom-10 border-bottom-1 margin-bottom-10">
<!-- LinkButton -->
<div class="small-6 medium-2 xlarge-1 columns">
<asp:LinkButton data-reveal-id="replyModal" CommandName="Contact" CommandArgument='<%#Eval("MessageId")%>' ToolTip="Reply" runat="server"><img src="/images/icon/envelop.jpg" alt="Contact Us"><strong class="font-size-14">Reply</strong></asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
In the .aspx.cs file
public void rptNotice_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
lbMessage.Text = "MessageId: " + e.CommandArgument.ToObjectString();
}
There seems to be possible parsing issue due to unknown parameter. I would suggest using CommandArgument field. Try "replyModal" to CommandArgument .
Split the value at backend and get operation type.

asp.net not able to set Image.Visible to true

This is my Default.aspx
<div class="well">
<asp:DropDownList ID="ddlSchools" runat="server"></asp:DropDownList>
<br /><br />
<asp:Button ID="btnContinue" runat="server" Text="Fortsätt" CssClass="btn btn-primary" OnClick="btnContinue_Click" />
<br /><br />
<asp:Image ID="loadingImage" ImageUrl="Images/ajax-loader.gif" runat="server"/>
</div>
I set loadingImage.Visible = false in Page_Load, then i want to show the loadingImage when i hit btnContinue, this is the method i call in Default.aspx.cs, i
protected void btnContinue_Click(object sender, EventArgs e)
{
loadingImage.Visible = true;
ApiHandeler.getSchoolData();
Response.Redirect("Overview.aspx");
}
However the image is still hidden. What am i doing wrong?
You perform redirect to another page right after you set the image visibility. The image would be visible if you stayed on the same page. I think you need to set style="display:none" and handle the client side onclick like $("#loadingImage").show(); - in that case you can use simple HTML image <img src="..." /> without runat="server"

Display Modal Popup On Button Click

I want to show modal popup after I click the Save button to save values in DB and while showing modal popup, it should continue saving, without closing modal popup
I am using this code
protected void btsave_Click(object sender, EventArgs e)
{
ModalPopupExtender1.Show();
//My Code
}
and my aspx code
<input type="button" runat="server" id="btmodel" style="display: none" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btmodel"
PopupControlID="Panel1" PopupDragHandleControlID="PopupHeader" Drag="true" DropShadow="true"
OkControlID="OkButton" CancelControlID="CancelButton" BackgroundCssClass="ModalPopupBG">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="Panel1" Style="display: none" runat="server">
<div class="progress-popup">
<div class="potit">
Saving
</div>
<img src="/images/prog.png" alt="" style="margin: 0 auto; display: block;" />
<div class="potit-cancel">
<span class="cncl">
<asp:Button ID="btnOkay" runat="server" Text="Ok" OnClick="btnOkay_Click" ValidationGroup="vg"
CssClass="popupcancl" />
</span>
</div>
</div>
</asp:Panel>
With this code, It first Saving Data in DB, then showing Modalpopup
add a hidden field on your page. Assign to it a value (let say, 'showed') when you press the button and then, in page_load, with string.compare, see if the value of the hidden field is 'showed'. If it is, then show again the modal control. When you press the cancel button, delete the value from hidden field (make it string.empty).

Getting rid of the Refresh on button click

I have a asp:Button that has an onclick function. Is there a way to eliminate the refresh that occurs?
Current HTML containing button.
<div id="user" class="font">
<div id="userPanel">
<asp:TextBox ID="txtSearch" runat="server" Width="400px" align="left"></asp:TextBox>
<asp:Button ID="searchbutton" text="enter" runat="server"
onclick="searchbutton_Click" />
<asp:Label ID="test" runat="server"></asp:Label>
</div>
<asp:UpdatePanel ID="userinfoupdatepanel" runat="server">
<ContentTemplate>
<div class="topcontent">
<ul>...</ul>
</div>
</ContentTemplate>
</asp:UpdatePanel>
The button click then calls a function that fills the UL content
You can use OnClientClick to bind a Javascript function to handle the click in the browser. If you return false from that fumction, the postback doesn't happen.
You can also add client events using Attributes collection.
searchbutton.Attributes.Add("onclick", "alert('Test')");
searchbutton.Attributes.Add("onclick", "return fnSomeThing(this);");

Categories

Resources