How to hide a particular text in a textbox for wp7 - c#

In my web browser app for wp7, i have a textbox for the URL's(named as UrlTextBox), in that i don't need the http:// to be visible even when the page is navigating or navigated. I don't know how to hide a particular text in a textbox. If i try to omit the http:// permanently then there will an error in my app. Can anybody help me with this? Thanks in advance for your help!

I'd guess you're probably doing something like:
webBrowser.Navigate(urlTextBox.Text);
Instead you could just do:
webBrowser.Navigate("http://" + urlTextBox.Text);
Obviously with appropriate checks, etc.
OR
if (urlTextBox.Text.StartsWith("http://")
{
urlTextBox.Text = urlTextBox.Text.SubString(7);
}

Related

How do I remove the unnecessary header on top of onMaster Detail Page with Xamarin.Forms

I am trying to develop an application with MasterDetailPage. But I came into a problem, whichever page I go to, there is always this blue header that put an unnecessary padding into my application. Is there anyway for me to get rid of it?
Thank you so much, I appreciate any help/advice I can get.
NavigationPage.SetHasNavigationBar(this, false);

How to implement an if else condition in the code behind for ImageButton OnClick

I am working on my website design and have already implemented a simple slideshow consisting of image buttons that would redirect users to different pages when they click on them. However the issue that I've noticed is that all of the images redirect users to the same page and I realized it was due to all the Images in the slideshow inheriting the method Response.Redirect("url")...then I tried to use an if else condition for example
if(ImageButton3.ImageUrl=="/Images/Homepage_Button.PNG")
{
Response.Redirect("Homepage.aspx");
}
However I have noticed that this method does not work. Do you guys have any suggestions, huge thanks in advance!!!
I would suggest you use a data-url attribute on your image buttons. When you post back you can get the url off the ((ImageButton)sender).Attributes("data-url") and redirect to that url.
Another suggestion, if you aren't doing anything else in the event handler, you could simply use links around images.
Did you try to debug this code? To see if it reaches the URL you specified?
You can do that by clicking on "Start with Debugging" in Visual Studio.
Another good bug ugly debugging method is to add an alert (MessageBox) inside the if sequence and see if it gets there. For example:
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", ("The URL is " + ImageButton3.ImageUrl));
if(ImageButton3.ImageUrl=="/Images/Homepage_Button.PNG")
{
Response.Redirect("Homepage.aspx");
}
Edit: After seeing your comment, I suggest accessing this image like that (notice the #):
if(ImageButton3.ImageUrl=="#Images\Homepage_Button.PNG")
{
Response.Redirect("Homepage.aspx");
}

How to display a website only in the default browser

I'm currently having an issue after a click on an hyperlink inside a wpf Page.In my RequestNavigate or Click (both have the same behavior in this situation) event I do the usual Process.Start(hyperlink.NavigateURI).The problem is that this event opens the webpage both in the default browser (the behavior I'm looking for) and in my wpf Page object as well which I don't want.I was wondering if there was any workaround for this issue? Thanks in advance.
You need to set e.Handled = true to say you have already handled the hyperlink
See Example using Hyperlink in WPF
The reason your current page also loads with the Url is because you are using a Hyperlink. Try using either a Hyperlink with no Url, a button or a styled Label

WebPage Render Position Controller

First question but I really am in a jam.
I have a webpage render which is working perfectly. However, I need to be able to control the initial display position (almost like a href #anchors in HTML) but without any access to the site content.
From as far as i can see i have no access to the scrollBars other than the bool to enable / disable..
Is there anything i can do to even force a scroll down of 20% for example, and then I can create a form to adjust later on.
Any assistance would be HUGELY appreciated although from what I have researched it seems unlikely.
I have the regular windows WebBrowser Render
private System.Windows.Forms.WebBrowser m_webBrowser;
Thanks !
--This is for c# standalone application.. Not WebBased.
Have you tried using jquery?
I personally use the animate method from jquery to scroll to certain elemnts in my webpage.
Example:
$('html, body').animate({scrollTop: $('#the-element-you-want-to-scroll-to).offset().top}, 1000);
PS: For the last parameter you can control the time it will use to scroll to destination, that offering you a nice effect.(in milliseconds)
I managed to resolve it using a strange method..
I basically injected some javascript into the rendered HTML manually.. Then the rest was easy.
i used something like this :
string updatedSource = WebBrowser.DocumentText.Replace("Google", "Foogle");
string extraSource =
"<html><body>Script goes here <br/>" +
"<div><p>BLA BLA BLA</p></div></body></html>";
WebBrowser.DocumentText = extraSource + updatedSource;
WebBrowser.Update();
Maybe it will help someone.

Gecko usage in C# (geckofx)

There are some things that I didn't find how to do using geckofx:
Get the URL of a clicked link.
Display print preview window.
Does this functionality exist in geckofx? If not, what's the best way
to achieve it in a C# project that uses GeckoWebBrowser to display html pages?
Thanks
To get url of clicked link you can use:
void domClicked(object sender, GeckoDomMouseEventArgs e)
{
if(geckoWebBrowser1.StatusText.StartsWith("http"))
{
MessageBox.Show(geckoWebBrowser1.StatusText);//forward status text string somewhere
}
}
To show print dialog box you can use:
geckoWebBrowser1.Navigate("javascript:print()");
OnNaviagted event should give you the link, and look for the print interfaces nsIPrintingPromptService::ShowPrintDialog in Geckofx.
geckoWebBrowser.url
That will give you the url at any point I believe where geckoWebBrowser is the name of the control, however as pointed out you'll be able to get it from the document completed and navigated events using e.url .
For printing, see this forum thread. Make sure to read it all before starting. Essentially you'll have to patch and recompile GeckoFX.

Categories