Opening web page on default Web browser and hiding URL parameters - vb.net

I have an application that needs to open an external URL on the default Web Browser but I don't want to show the parameters on the URL so I think I need to make a POST instead of a GET, but how?
I'm using the following code to open an external default browser
Friend Sub WebOpen(ByVal WebAddress As String)
Dim sInfo As New ProcessStartInfo(WebAddress)
Process.Start(sInfo)
End Sub
But this expose all the parameters on the URL bar since make a GET not a POST.
Solution:
Make a temporary HTML file and open it using the previous code (WebOpen(ByVal WebAddress As String))
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<!-- <head>
</head> -->
<body>
<form name="Login" method="post" action="http://www.yourWebPage.com/" target="_self">
<input id="accountLoginField" class="textInput" name="account" value="accountX" size="24"
maxlength="32" type="hidden"/>
<input id="userLoginField" class="textInput" name="user" value="userX" size="24"
maxlength="32" type="hidden"/>
<input class="textInput" name="password" value="PassX" size="24" maxlength="32" type="hidden"/>
<input name="submit" value="Start Session" type="submit" id="btn" style="color: transparent;
background-color: transparent; border-color: transparent; cursor: default;"/>
<script type="text/javascript">
<!--
var counter = 0;
var maxCount = 50;
function pushSubmit() {
if (counter++ < maxCount) {
document.getElementById('btn').click();
}
}
//start the process
window.setTimeout(pushSubmit(), 30);
</script>
</form>
</body>
</html>

Hopefully you were able to find your answer using an older post from here: How to open IE with post info in C#?
Please mark this as an answer if this helped you solved your issue.

You could use a string encryptor in vb.net (you'll have to find that yourself) and then do this:
Process.Start(Decrypt("encryptedstringhere"))
That will 'hide' the parameters from anyone trying to decompile your code.
OR
Once you have compiled your executable, find a vb.net obfuscation program (just google it) and obfuscate your exe. This will make it unreadable to nayone who attempts to decompile it or find what string is in your parameters....
Hope this helped!
Rodit

Related

Razor class library and html helpers problem

I create a small admin tool and I decided to convert it to a Razor class library so that I will be able to use it in other applications as well. I created the Razor Class Library project and I added all the razor pages that I had in my main project and I tried to test the new project. The problem was that the framework for some reason did not recognize the html helpers so I created a new clean project and try to find out what is wrong and the result was that the application did not fire the post action of the razor page and the asp-for property was not using properly the property value. I used the following code in order to test the Razor Class Library.
Page1.cshtml.cs
public class Page1Model : PageModel
{
[BindProperty]
public Input MyInput { get; set; }
public class Input
{
public string Name { get; set; }
}
public void OnGet()
{
}
public void OnPost()
{
}
}
Page1.cshtml
#page
#model WebApplication1.MyFeature.Pages.Page1Model
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Page1</title>
</head>
<body>
<form method="post">
<input asp-for="MyInput.Name" /><br />
<input type="submit" />
</form>
</body>
</html>
The generated html was the following
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Page1</title>
</head>
<body>
<form method="post">
<input asp-for="MyInput.Name" /><br />
<input type="submit" />
</form>
</body>
</html>
As you can see the input for MyInput.Name appears as I typed it the Page1.cshtml file. The right output shoud be the following:
<input type="text" id="MyInput_Name" name="MyInput.Name" value="" /><br />
Do I have to do something in order to make the html helpers work and the OnPost action to be called when a post request occurs?
I found the solution to the problem and I decided to share it with you just in case someone else has the same problem.
In order to make it work I had to add the file _ViewImports.cshtml in the pages folder of the Razor Class Library and add the following line:
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

browser-sync onchange event not fired on mirrored browsers

Browser-sync has a feature called "Interaction sync" that allows you to "scroll, click, refresh and form actions are mirrored between browsers while you test.", however it doesn't seem to work for the onchange event.
While React component `onChange` event not being triggered when synced with BrowserSync refers to it not working for React, it doesn't even work in a simple html with js.
A number of the forms we use have conditionally dependent fields, and this prevents you from completing a form of this type. Is there a way around this?
I have included a simplified version of this form below. To test this out:
take a copy of the below snippet and save it as an html file
navigate to the directory containing the html
open a command prompt, navigate to the html file, and run
browser-sync start --server
browser-sync will launch a browser containing the default url (http:localhost:port), append "/test.html" to the url
copy the url to another browser
You'll see that while the selection of the dropdown mirrors, the event and associated javascript don't fire.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<style>
.hide{
display:none !important;
}
</style>
</head>
<body>
<form>
<h1>Conditional Form</h1>
<label>dependee</label>
<select name="radioGroup" id="radioGroup" onchange="displayDependent();">
<option value="-1">--</option>
<option value="radio1">radio1</option>
<option value="radio2">radio2</option>
</select>
<div id="text1Group" class="hide">
<label>text1</label>
<input type="text" name="text1">
</div>
<div id="text2Group" class="hide">
<label>text2</label>
<input type="text" name="text2">
</div>
<div id="text3Group">
<label>text3</label>
<input type="text" name="text3">
</div>
</form>
</body>
<script src="http://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script>
function displayDependent() {
var dropDownSelect = document.getElementById('radioGroup').value;
// hide both
if (dropDownSelect == "-1") {
$("#text1Group").addClass("hide");
$("#text2Group").addClass("hide");
}
// show 1 hide 2
if (dropDownSelect == "radio1") {
$("#text1Group").removeClass("hide");
$("#text2Group").addClass("hide");
}
// show 2 hide 1
if (dropDownSelect == "radio2") {
$("#text2Group").removeClass("hide");
$("#text1Group").addClass("hide");
}
}
</script>
</html>
Doesn't look like it is available at this time.
Stumbled upon this github issue, shortly after:
https://github.com/BrowserSync/browser-sync/issues/22

Need help with post request portion of reCAPTCHA api

I hardly know anything about POST request or api's , so the more explicity you can make things, the better.
I'm going through the description of adding a reCAPTCHA to my site but I'm stuck on the verification portion. Here's the part I'm stuck on: http://code.google.com/apis/recaptcha/docs/verify.html
I don't know how to do a POST request. If someone could explain this portion to me that would help greatly.
Here's the code I have on my site so far, copied directly from http://code.google.com/apis/recaptcha/docs/display.html#Standard:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<body>
<!-- ... your HTML content ... --> <form action="" method="post"> <!-- ... your form code here ... --> <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=public key"> </script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=public key" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript> <!-- ... more of your form code here ... --> </form> <!-- ... more of your HTML content ... -->
</body>
</html>
either use te recaptcha PHP/Perl/Asp/.. plugin or use the recaptcha ajax library which handles everything with javascript so you dont need server side scripts.

Add Dynamically Links to jQuery Mobile

I read a lot about how to add stuff dynamically in jquery mobile, but I couldn't figure out how to add links.
Currently my solution looks like this:
Add a new Page - with id (id="list-1")
Creating a Link for it (href="#list-1")
This solution works perfectly in static pages, but I want to do it dynamically. I have tried a lot with page() and stuff like that but nothing helped me.
My questions are:
How do I add dynamic links & pages?
Did I choose the right way to use ids & anchors (#list-1) as links or is there another solution for jquery mobile?
Let me know if you need more information
To add dynamic links, I have found the easiest way is to just have an event listener waiting for a click on those links. This event listener then saves any parameters you want to pass into the next page you are visiting. You pass the parameters from the list element to the event listener by just specifying parameters within each "li" element.
(create the HTML for a list dynamically & store it into list-1-html)
$("div#my-page div[data-role=content]").html(list-1-html);
$("div.list-1 ul").listview();
$("div.list-1 ul").listview('refresh');
Then your event listener would look something like:
$('#my-page').delegate('li', 'click', function() {
passedParameter = $(this).get(0).getAttribute('passed-parameter');
});
When jQuery Mobile loads your next page, you'll probably want to load this page dynamically and you'll have this passedParameter variable available to you. To load the page dynamically, just add a listener that waits for JQM to try to load the page:
$('[data-role=page]').live('pageshow',function(e, ui){
page_name = e.target.id;
if (page_name == 'my-page-2'){
(do something with passedParameter)
}
});
This is the workflow I use with jQuery Mobile and it has been working just fine. I'm guessing in future releases, though, that they'll build in some kind of support for passing dynamic parameters to pages.
Any new enhancement to the DOM should be done before the page initializes. But by default JQM automatically initializes the page once the page is load in browser.
Hence first you need to set autoInitializePage property to false and then call initializePage() method after the new page and links are add to the document. Hope this helps.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
$(document).bind("mobileinit", function(){
$.mobile.autoInitializePage = false;
});
</script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script>
$(document).ready(function() {
//add a link.
$("#page1 div[data-role='content']").append('Next Page');
//add a page.
$('body').append(' <div data-role="page" id="page2" data-title="next page"><header data-role="header" class="header"> <h5>Page 2</h5></header><div data-role="content"><h3>Good Morning...</h3>Back</div><footer data-role="footer" data-position="fixed"><h5>© All rights reserved</h5></footer></div>');
});
window.onload = function() {
$.mobile.initializePage();
};
</script>
</head>
<body>
<div data-role="page" id="page1">
<header data-role="header" class="header">
<h5>jQuery Mobile</h5>
</header>
<div data-role="content">
<form method="get" action="" data-transition="slideup">
<label for="email">Email:</label>
<input type="email" name="email" id="email" value=""/>
</form>
</div>
<footer data-role="footer" data-position="fixed"><h5>© All rights reserved</h5></footer>
</div>
</body>
</html>

How to refer to a control that exists within an Ajax Tab?

I have a problem with using a script that adds a NiceEdit toolbar to a text area when that text area is within an Ajax tab.
I want to know if I should refer to it in a different way than just the ID.
I mean the ID of that text area, I tried to take the text area outside the Tab Container, it works, but when I return it, it simply doesn't.
<%# Page Language="VB" ValidateRequest ="false" AutoEventWireup="false" CodeFile="tabbedNiceEditt.aspx.vb" Inherits="Client_tabbedNiceEditt" %>
<script src="../nicEdit/nicEdit.js" type="text/javascript"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor({buttonList : ['fontSize','fontFamily','fontFormat','bold','italic','underline','strikethrough','forecolor','bgcolor','removeformat'], iconsPath : '../nicEdit/nicEditorIcons.gif'}).panelInstance('txt');
});
</script>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function pageLoad() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<cc1:TabContainer ID="TabContainer1" runat="server">
<cc1:TabPanel ID= "first" runat ="server" >
<ContentTemplate>
<b>Stuff Goes HERE</b>
<br />
<asp:TextBox ID = "txt" name = "txt" runat ="server" TextMode ="MultiLine" Height = "256" Width = "256">
</asp:TextBox>
<br />
<br />
<asp:Button id = "btn" runat ="server" Text = "click" />
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID = "second" runat ="server" >
<ContentTemplate>
<b>More Stuff for second tab</b>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</div>
</form>
</body>
</html>
txt is the server ID of your control, you have to use the client ID :
....panelInstance('<%= txt.ClientID %>');
Basically, the client ID is derived from the server ID and the naming container where your control is, to avoid any naming conflict. When your text area is not in the Ajax Tab, the client ID is the same as the server ID. When you put the text area in the Ajax Tab, it's client ID is different (you can check that by looking at the page source in your browser).
EDIT:
From Maen
I viewed the page in browser, checked
the ID in the page source, it was
"TabContainer1$first$txt", used it
instead of "txt" and the script was
like: panelInstance('<%=
txt.TabContainer1$first$txt %> I got
an error: BC30456: 'TabContainer1' is
not a member of
'System.Web.UI.WebControls.TextBox'.
That's not what I meant : you have to put panelInstance('<%= txt.ClientID %>') in your source code, and asp.net will convert that to panelInstance('TabContainer1$first$txt').
I told you to check the page source in the web browser just to see that the client Id was no longer "txt", but that it was constructed from the server ID and the naming container.