Issue with Popup - c#

I am using a window.open() in a hyperlink to open a popup in my page. I have a folder structure like
parent
Controls
Reports
reportviewer.aspx
Search.aspx
form search.aspx i need to open reportviewer.aspx in a popup(javascript) .How to achive this ?How to pass the url ?

In current situation the path could be
window.open("reportviewer.aspx")
but i think better way is to use ResolveUrl or ResolveClientUrl
Try something like that:
<asp:HyperLink runat="server" OnClientClick='<%# string.Format("window.open(\"{0}\");
return false;", ResolveUrl("~/AppFolder/YourPath/reportviewer.aspx"))%>' NavigateUrl="#" %>

Try this:
Button1.Attributes.Add("onclick", "javascript:window.open('/reportviewer.aspx');");

Since both reportviewer.aspx and search.aspx are in the same folder,
the url can be passed as under
window.open('reportviewer.aspx');

Take care of opening windows in pop-ups because some navigators are bloking popups. It causes me some explications about navigator's security to users.
I'm now using NyroMal it's a jquery plugin to make popups "in the page". No blocking..
there's some tutorials in the project's web site to learn how it is working..

Related

User Control - (An entry with the same key already exists)

I am working on a SharePoint 2016 Project which uses SharePoint Application pages. We have a separate user control to which is used to capture address and it is used in other parts of the application.
In order to use this, I have added the user control in to the SharePoint application Page as follows.
<%# Register TagPrefix="uc" TagName="StreetAndPostalAddress" Src="~/_controltemplates/15/Test.Features.WebParts/QAS/QASAddressStreetAndPostal.ascx" %>
And tried to use this control in the page as below.
<uc:StreetAndPostalAddress id="locationAndPostalAddress" runat="Server" />
As soon as I add this control to the page it gives me an error as below. I have tried but was unable to figure out a clue on this. Main reason was same control was working on a another page. Please share your thoughts to resolve this.
Thank you.
I noticed the page used a update panel as follows
<asp:UpdatePanel ID="UP_Accordion" runat="server" UpdateMode="Conditional" ClientIDMode="Static" >
Any Idea on what is the use of it?
First Solution
It was defined <%# Control ClientIDMode="static" > in the page and once I change it to <%# Control ClientIDMode="Predictable" > the issue got resolved. But the functionality of the page is not working. Because JavaScript/Jquery is not working. Which Still did not resolve my issue :(
Finally I figured out why the page is not working. It consists of a accordion and a Grid. And I had a requirement to repeat a same user control. Due to the ClientIDMode which was set to static I had the above error. I read this areticle to understand the concept of ClientIDMode and removed it from the page. Use below link to learn it.
1) https://weblog.west-wind.com/posts/2009/nov/07/clientidmode-in-aspnet-40
Once I removed the ClientIDMode it seems my jquery in the page is not working. I had to change the jquery selector for ID and had select using a pattern match. Once changed the page rendered correctly.
2) How to stop ASP.NET from changing IDs in order to use jQuery

How would I let 1 .aspx page use another .aspx page's code?

I have 2 aspx files in my project. The first.aspx page has some content on it and when I click on a button, it will launch a frame (second.aspx that only has code to show a calendar) on the same page.
Now once that calendar(second.aspx) loads on first.aspx, I want to click a link on the calendar that will .show() a hidden DIV on the first.aspx page.
How do I access code cross pages? In other words, how can I write some code in second.aspx that will affect first.aspx.
What you're asking for is not really possible. You're probably approaching it the wrong way. What you should do is turn your calendar page into a user control so that it can be used seamlessly in first.aspx.
Here is how to get started with user controls in asp.net:
After you turn it into a user control there are different approaches to getting access to the properties of the user control from your page. Here is one approach using the FindControl method.
Hope that helps.
The easiest solution would be to show and hide your div with jquery. Simple give your div a class like:
<div class="myCalendarDiv" style="display:none" />
And your Button should look like this:
<asp:Button id="myButton" OnClientClick="return ShowCalendar();" runat="server" />
<script type="text/javascript">
function ShowCalendar() {
$(".myCalendarDiv").show();
return false;
}
</script>
Another way would be instead of creating a seprate webpage for the calendar, as proposed you can use a jquery dialog, or make a usercontrol and embedd it on the same page.
(Posted on behalf of the OP).
So since I was dealing with an Iframe, I found out that you can target the parent window which would be first.aspx.
I used "window.parent.MYFUNCTION();" to call my JavaScript function on first.aspx and show the div.

Force html link to open in a new window

There's no easy way to explain this but, I have a website, that links to a online game I've made using asp C#. The website has a link to the game so when the user clicks the link on the site, my game pops up! Simples...
But I want it to pop up in a new Window! but not a browser window... Just... A Window :s
for Example, if you go on www.dofutoshiki.com and click on the "Play Futoshiki in our online player" link, it opens a new window with, just the game. No browser functionality.
I was wondering if anybody out there could shed some light on the subject...
Ive Tried:
Click me!
but it just opens a new tab in the browser!
Thanks!
Alex
If I get this right, you actually want a browser window but without the chrome/UI.
For this, you need to use window.open() (javascript) rather than a target attribute.
http://www.pageresource.com/jscript/jwinopen.htm will help you.
You have to open the new window by using javascript and disabling the unwanted functionality by passing arguments.
You will probably need some javascript for this. What you need to look in to is the
'window.open(...)' function.
Here are a few examples.
And here you can play around with it.
Use javascript Window.open method
Click me!
<script>
function openGame(){
window.open(blahblah.aspx,'Play Game','width=900,height=790,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=n o,menubar=no,status=no,resizable=yes');
}
</script>
You can use Jquery popup window plugin it is easy to use and more flexible also.
http://swip.codylindley.com/popupWindowDemo.html
On site you are referring to, browser window is opened. It's configured so that it does not have toolbar, status bar, menu bar, etc.
You can take a look at window opening code in HTML source of the page you are referring to:
<a onClick="window.open(this,'playsample','width=900,height=790,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=no,menubar=no,status=no,resizable=yes');return false;">
Is javascript an option?
With javascript it would be something like this:
<a href="#" onclick="window.open('blahblah.aspx', 'game','status=0,toolbar=0,width:400,height:300');" > Click here for the game! </a>
Use this
Click me!
Or even better, put the onclick code in a function of your own so you can reuse it.

LinkButton open new window tab

<asp:LinkButton ID="lnkbtnMoreTagRules" runat="server"
CommandName='<%#Eval("Value")%>'
CommandArgument='<%# string.Format("{0}||||{1}", Eval("Tag"),
Eval("TagAppearance"))%>'
OnCommand="lnkbtnMoreTagRules_Command">Več pravil</asp:LinkButton>
I want to close current window tab and open new one.
How can i open a new window tab with linkbutton. target="_blank" not helping.
As link button is posted back, so it cannot be used for a GET request. instead use HyperLink Class
LinkButton works like a Button and does not have a Target attribute. Use a HyperLink instead and set the Target.
You need something like this
<asp:LinkButton id="LinkButton1" runat="server" onClientClick="window.open('http://asp.net');"
I doubt we have any foolprrof code to open link in tabs because most of the browser activities are totally under the control of users.
User can change thier browser settings in the way they wanted to behave.
There is nice discussion related to this in below thread, it will be interesting for you,
http://www.dynamicdrive.com/forums/archive/index.php/t-19843.html

asp: LoginStatus control as a button, not text

I'm pretty new to this, infact this is my first post.
I'm using Visual Studio 2005. On my .aspx page, I have a 'loginStatus' control so the user can logout of a page which works well. However the 'loginStatus' control is not a button, it's text ("logout"). Is it possible to make this into a button?
Here is the line of code:
<asp:LoginStatus ID="LoginStatus1" runat="server" OnLoggingOut="LoginStatus1_LoggingOut" />
Would I just add some style somehow? If so, please help me.
Thanks.
Haven't tested this, but it might solve your problem : forum post
Otherwise you might use jQuery to solve this. (I think...)
You can try this:
<asp:LoginStatus ID="HeadLoginStatus" runat="server"
LogoutAction="Redirect"
LogoutText="<input type='button' value='Log Out' />"
LogoutPageUrl="~/"/>
The LogoutText attribute contains the definition of a simple button, that you can customize with css and js.
Just use LoginImageUrl or LogoutImageUrl
<asp:LoginStatus runat="server"
LogoutImageUrl="~/App_Themes/Theme1/Images/logout.png"
LoginImageUrl="~/App_Themes/Theme1/Images/login.png" />
Using JavaScript:
Grab the url of the link and add a button which, when onclick'ed, points the browser to that url. Then add display:none to the original link with CSS.
You can also use an image as Colin says, but that would fake a button and I assume you want a real button.
YOu could try to render it using an Image, as stated here
The LoginStatus control displays either a text or an image link, depending on the setting of the LoginImageUrl and LogoutImageUrl properties. You can display either text or images for one or both states.
Cheers, I will have a look into this :)
I think it's strange that the option of turning it into a button is not already available.
You could wrap the LoginStatus inside of a LinkButton (Or any kind of button).
<asp:LinkButton id="LinkButton1" runat="server">
<asp:LoginStatus id="LoginStatus1" runat="server" />
</asp:LinkButton>
then use the LinkButton1 events.
You could always just extend the LoginStatus control by creating a derived class, and overriding the rendering behaviour to change the output elements into your desired elements, or add style attributes, or whatever.
(apologies for VB)
Public Class MyLoginStatus
Inherits System.Web.UI.WebControls.LoginStatus
Public Overrides Sub RenderBeginTag(ByVal writer As System.Web.UI.HtmlTextWriter)
writer.AddStyleAttribute("display", "none")
MyBase.RenderBeginTag(writer)
End Sub
End Class
This kind of behaviour could be extended to turn the output into a button, if you so wish, either in aggregate (modifying the final rendered output by creating your own HtmlTextWriter enclosing a StringWriter and invoking the base methods), or by injecting your own behaviour into the relevant render events.
Have you looked into Control Adapters - this allows you to alter the HTML generated. It's primarily used for adapting HTML for different browsers and devices, but can be used to have complete control over server controls.
Lee
I know this is an old post but I'll chime in.
Here's a very simple way to make a button out of the LoginStatus control. Set the control CssClass to a bootstrap button and your good to go. Whatever text you have for the login and logout will go into the button.
<asp:LoginStatus ID="LoginStatus1" runat="server" CssClass="btn btn-primary" LogoutPageUrl="yourlogin.aspx" />
http://www.w3schools.com/bootstrap/bootstrap_buttons.asp

Categories

Resources