A Simulation to Disable Page Elements and Display UpdateProgress Control - c#

Am trying to disable page elements & display update progress control in my application. To make it work, I have applied style sheet with the property
filter:alpha(opacity=85);
but its showing an error "filter is not a known CSS property name".
Can anyone suggest me what can be done for this?
Also give me an idea of disabling page elements when displaying update progress control?

Filter is IE specific, use Opacity for other browsers.
http://www.quirksmode.org/css/opacity.html

Try this
<!--[if IE ]>
.youeElemet{
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=85)"; // first!
filter: alpha(opacity=85);
}
<![endif]-->

Related

How to show a hyperlink in a text

I have a text which may contain some special characters like <b></b> or a link. I want the user to be able to click on the link and open it. TextBlock or RichTextBox seems doesn't show links in a proper way:
<RichTextBox >
<Paragraph>
click here: http://www.google.com
</Paragraph>
</RichTextBox>
How can I show a text like that in a page?
Update: seems my question isn't clear. I ask a server for content and it returns back to me something like this:
from <b><i><a href="http://www.google.com" rel=nofollow> lorem ipsom
NPR:

 tapped in front of you probably know Bill Gates...
I want to show this in a WINDOWS PHONE page. TextBlock doesn't render it well. how can I show it human readable?
The way to solve your problem I see in using of WebBrowser control.
Then, accordingly to the article, you should go with Javascript to manage the links clicking etc (unless you want the links would be opened automatically with standard logic of Windows Phone):
Script is disabled in the WebBrowser control by default. Set the
IsScriptEnabled property to true if you want to enable scripting in
your control. You can then call scripts using the InvokeScript method.
The ScriptNotify event occurs when JavaScript in the WebBrowser
control passes a string to managed code.
That's a bit tricky way, but if you want to go any other way, you would have to implement your own parser of the code and build the sentence with labels and custom hyperlinks (as in provided above suggestions from comments).

Displaying a content page as popup in asp.net,using

I have a content page(Say.. invoice.aspx) in asp.net application with master pages.
The content page(invoice.aspx) is using a gridview, which displays records from database.
Currently i am navigating to this page using - Response.redirect("invoice.aspx") and this is working fine.
But i need to display this page as pop-up from calling page, so that this popup invoice can be seen on the top of other pages.
Please help me if this can be done using javascript or some other way.
Thanks in advance..
A page popup can be implemented using a div as a container with a different style (opacity, window position, size etc) and has a higher z-index than the rest of the page.
thus basically you need a structure like
<div class="overlayOuter">
<div class="overlayInner">
<!-- external content to be loaded here -->
</div>
</div>
and now using AJAX you load the invoice.aspx page to the inner container and show the container and reduce the opacity of the outer container.
There should be libraries out there that let you do this. you need to explore that on your own.
You can use modal popups for the above scenario:
one example can be found here: http://sandbox.scriptiny.com/tinybox2/
its easy and not much code you need to write and also can load popup as an iframe so postbacks can be handled without posting back parent page or you can use ajax
function OpenWindow(strChildPageUrl) {
var testwindow = window.open(strChildPageUrl, "Child", "width=700px,height=650px,top=0,left=0,scrollbars=1");
testwindow.moveTo(100, 0);
}
</script>

Check if (mobile)browser support background images

I am building a mobile site and the footer has an background.
I want to check if the browser supports css property, background-image, if true display background with specific html, else display a different set of html.
I am using the following :
HttpBrowserCapabilities bc = new HttpBrowserCapabilities();
I can't seem to get a check for backgrounds.
The reason why I want to check for BG-image support is coz I have to switch between 2 sets of html. 1 with html text and bg image, and the other with the text on the image - sliced for each word/link...to give the same effect.
to get information by HttpBrowserCapabilities, you have to use Request.Browser property.
HttpBrowserCapabilities browerCapabilities = Request.Browser;
I think Asp.net will automatically check the type of the browser and render the page accordingly. So if the the browser don't support background images it will not come.
Another idea to solve the issue is getting the browser type by using code, then you can show or hide the background images based on the type.

How to use webbrowser control to turn the div visibility into visible?

I'm currently using System.Windows.Forms webbrowser control to automate a webpage. Everything works fine to manipulate the htmlelement through webbrowser.document. However unfortunately i have to click a button which is embedded in a hidden div. so my question is, how should i turn this div 's visibility to visible and click on the button in it?
This is the div which is visible after it has been turned into visible:
<div class="box" style="visibility:visible">
<button />
</div>
Ps: the div doesn't have id but only class name (so i think it is dealing with css style)
Since i'm not able to detect with webbrowser.document , how can i retrieve it ? or how can i change the css of class = box using webbrowser.document?
Try:
yourWebBrowserControl.Document.All["YourButton"].InvokeMember("click");
If I can ask for a bit of clarification: what are you trying to accomplish?
The webbrowser control essentially encapsulates the IE rendering engine and allows you to navigate to a document or URI. When you click this button, are you navigating somewhere? Or is this a form to be submitted?

Remove statically added controls at runtime

The Scenario: I have an asp.net website where I show a div popup on page load for taking a few user details. When a user inputs the details, or closes the popup, I set up a flag cookie so that the popup is not displayed again for the user. The div is in the MasterPage so that it is displayed no matter on which page a user lands first time. The div contains an UpdatePanel which has all the controls required for taking the details. This whole functionality is working fine.
The Problem: Now this div popup is not showing(by setting display:none) on subsequent postbacks(which I want), but the html markup is still loading with the page unnecessarily adding to the page size. What I would idealy want to do is: Check if flag cookie is set. If no, show the popup, else remove the popup's markup from the page.
Now since the div is not a server control, I cannot possibly remove it and the all the controls inside it. So, I thought of removing the UpdatePanel from the page:
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["flag"] != null)
{
if (Page.Controls.Contains(updpnl_contact))
{
Page.Controls.Remove(updpnl_contact);
updpnl_contact.Dispose();
}
}
}
But I guess this tends to work with dynamically added controls only, and since the control is added at Design Time, it is not being removed.
Is there any way I can achieve this?
If you add a runat="server" attribute to your <div> element, it will be available in the code-behind. You'll need an id on it as well. Then you can just toggle the Visible property. If this property is false, the control won't be rendered to the client (i.e. no HTML markup).
What you're trying to do is not at all the usual workflow. I tend to think that it will not work as it would mess up control tree, maybe even corrupt the viewstate and so on.
As a possible solution, you can put it's visibility to hidden in the code behind. This, in the contrary to the usual 'gut feeling', doesn't work like the css propery 'display:none' for example - instead the control will not even be rendered into the page when it's not visible. This may be the workaround for you.
Happy coding.
A more efficient approach would be to create the panel as a UserControl and load it dynamically in codebehind when it's needed, then add it to your page. E.g, in code:
MyPopupControl popup = (MyPopupControl)Page.LoadControl("/path/to/usercontrol.ascx");
PopupPanel.Controls.Add(popup);
Where PopupPanel is an empty <asp:Panel>. Then, not even the markup will need to be loaded/processed except when its needed.
There is no reason that all the code you use to display and process this panel couldn't also be in the usercontrol, isolating it from the master page.
Can you build the panel dynamically, based on the cookie setting?

Categories