ASP.NET Web widget deployment - c#

I've created my first simple widget. It has some textboxes for input and output data and a button. After clicking it, it connects to web service through soap and send back needed data. Now, I've stumbled upon the issue of its deployment. What's the simplest way to deploy it on any sample site without it interfering with the content? How do I approach this and what should I do?
Here's my WebForm.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WidgetTest3.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<br />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
Thank you for your time.

The simplest way to deploy this from within Visual Studio is to use the Build -> Publish command and choose the File System publish method.
To prevent it from interfering with existing files, make sure that the "Delete all existing files prior to publish" is unchecked in the File Publish Options section of the Publish Web dialog.

Related

New to asp and don't understand why my text boxes are not visible [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Goal: Link html web page to Microsoft access file. This access file is very large and has columns titled: customer name, order number, street address, tracking number, and verified date. For the webpage we'd like asp textboxes and buttons that will search the microsoft access file in the back end.
We are using microsoft expression 4 to write the .aspx file and it renders correctly how we want in the design view. However, after copying the code (.aspx file) and placing it into notepadd ++ and saving it as an html file the buttons are not visible in the browser window. How can I convert the .aspx file to render on a browser? Thanks!
Here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<% # Page Language="C#" %>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Returns Received Report</title>
<style type="text/css">
.auto-style1 {
font-size: xlarge;
}
.auto-style2 {
text-align: center;
}
.auto-style3 {
margin-left: 0px;
}
.auto-style4 {
margin-left: 280px;
}
.auto-style5 {
margin-left: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<div class="auto-style2">
<body bgcolor="#black"><p></p>
<div class="auto-style2">
<br />
<br />
<strong><span class="auto-style1"><u>Search for a Return:</u><br/>
<br />
</span></strong>
</div>
<form id="form1" runat="server">
<div class="auto-style4">
<asp:TextBox id="Customer" runat="server" Visible="true" Width="261px" CssClass="auto-style5" Height="22px" BackColor="Black" BorderColor="Black"></asp:TextBox>
<asp:Button id="Button1" runat="server" Visible="true" PostBackUrl="Customer.aspx" Text="Search by Customer" BorderStyle="Outset" />
</div>
<br />
<br />
<asp:TextBox id="PO" runat="server" Visible="true" Width="261px" EnableViewState="True"></asp:TextBox>
<asp:Button id="Button2" runat="server" Visible="true" PostBackUrl="Order Number.aspx" Text="Search by Order Number" BorderStyle="Outset" Width="181px" />
<br />
<br />
<asp:TextBox id="ADDRESS" runat="server" Visible="true" Width="261px"></asp:TextBox>
<asp:Button id="Button3" runat="server" PostBackUrl="Street_Address.aspx" Text="Search by Street Address" BorderStyle="Outset" Width="181px" />
<br />
<p>
<asp:TextBox id="TrackingNumber" runat="server" Visible="true" Width="261px"></asp:TextBox>
<asp:Button id="Button4" runat="server" PostBackUrl="TrackingNumber.aspx" Text="Search by Tracking Number" BorderStyle="Outset" Width="181px" />
</p>
<p>
<asp:TextBox id="VerifiedDate" runat="server" Visible="true" Width="261px" CssClass="auto-style3"></asp:TextBox>
<asp:Button id="Button5" runat="server" PostBackUrl="TrackingNumber.aspx" Text="Search by Verified Date" BorderStyle="Outset" Width="181px" />
</p>
<asp:TextBox runat="server" id="TextBox1"></asp:TextBox>
</div>
<p> </p>
</form>
</body>
</html>
Your stated goal is to link your web pages to your Access databases. This is possible, but you'll need to do quite a bit of groundwork first. Yes, check out the Getting Started tutorials on asp.net, microsoftvirtualacademy.com, and so on.
However, you seem to be missing the basics. A HTML file is something that can be double-clicked on your desktop, and it will open up in a browser. An ASP.net page is designed to run on the server.
What this means is that when it's requested from the server, a certain amount of processing is done first, and then the server will generate the HTML that gets sent to your browser. This gives the server the ability to query your Access database, receive input, process input, and generate HTML on demand.
On Windows, you'll likely use something like IIS. If you download Visual Studio or WebMatrix, it will run a development server for you to test your code. When you're ready to deploy, you'll need a server (either locally, on your network, or from a third party hosting provider) for anyone to be able to see your pages.
.aspx files are template files that the server will populate with the data defined by the ASP calls. Renaming the file to html will not allow for the server to use the ASP calls, as they are no longer being processed by the server.

Use of Validation Group in asp.net

I can't not to use Validation Group in asp.net c#.
I have searched solution in Google without success.
In this simple form asp.net the TextBox pcs is always validated even when the value is null or the value is not a number.
My code asp.net below, what is wrong?
HTML:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="pcs" runat="server" Width="100" CssClass="ddl_Class" ValidationGroup="First"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="pcs"
ErrorMessage="PCS !" Text="***" Display="None" ValidationGroup="First"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidatorPcs" runat="server" ControlToValidate="pcs"
ErrorMessage="PCS only number" Text="***" Display="None" ValidationExpression="^\d+$" ValidationGroup="First"></asp:RegularExpressionValidator>
<asp:ImageButton ID="btnSave" runat="server" ImageUrl="/Images/save_button.gif" OnClientClick="return confirm('Confirm ?');" ValidationGroup="First" CausesValidation="true" />
<asp:ValidationSummary ID="First" runat="Server" ShowMessageBox="true" />
</div>
</form>
</body>
</html>
EDIT 1
The problem is the OnClientClick event.
If delete this event in asp:ImageButton the validation group working.
Why?
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="pcs" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="pcs"
ErrorMessage="PCS !" Text="***" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="pcs"
ErrorMessage="PCS only number" Text="***" Display="None" ValidationExpression="^\d+$" EnableClientScript="true"></asp:RegularExpressionValidator>
<asp:ImageButton ID="btnSave" runat="server" ImageUrl="/Images/save_button.gif" />
</div>
<asp:ValidationSummary ID="First" runat="Server"
ShowMessageBox="true" />
</form>
</body>
</html>
OnClientClick is a useful property introduced in ASP.NET 2.0 that allows us to add some client-side behavior to button control. Using is as simple as providing the script to be called when a button is clicked by a user:
<asp:Button runat="server" ID="Save"
OnClientClick="return confirm('Are you sure?');" />
The problem is that if you use it like that, client-side validation won't fire. Looking at the rendered HTML quickly explains the situation:
onclick="return confirm('Are you sure?');WebForm_DoPostBackWithOptions(...)"
As you can see, the validation doesn't even have a chance to fire (which happens when WebForm_DoPostBackWithOptions is called).
Solving the issue is simple (or not). All that has to be done is a little change in our OnClientClick script (a piece of code found somewhere on the Internet):
<asp:Button runat="server" ID="Save"
OnClientClick="if (!confirm('Are you sure?')) return false;" />
Now we only return false (preventing the submit) in case a user didn't confirm the action, otherwise, the rest of the script will be called thus firing validation.
The reason I said that it may not be a simple issue is the fact, that the validation happens AFTER the confirmation, which is not the best thing in my opinion. Why ask the user about saving his data if there are still errors on the form, of which we will inform him after he confirms that he wants to save it?
After analyzing a bit, the code responsible for dealing with OnClientScript, I have come to a conclusion, that solving this problem is not an easy task. It would require some dirty hacks on the server side to make it pretty or calling validation routines on the client, before displaying the confirmation dialog (keeping in mind that checking if there are validation routines present at all is necessary in this case).
Used From : http://vaultofthoughts.net/OnClientClickBreaksValidation.aspx

How to hyperlink list from Access database in C# ASP.Net

My assignment states: Create a site that is similar to Figure 8.9 in ASP.NET 4 Unleashed, but instead of a list of movie hyperlinks, create a list of your favorite activities (sports, reading, shopping etc.) The image in question is just a simple vertical listing of hyperlinked movies. I am running into issues as it will not build correctly though I have no errors or warnings. I do have a message that states
"Message 1 Validation (ASP.Net): Attribute 'ConnectionString' is not a valid attribute of element 'AccessDataSource'. c:\users\owner\documents\visual studio 2010\Projects\Activities\Activities\Activities.aspx 41 5 Activities"
My code is as follows
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Activities.aspx.cs"
Inherits="Activities.Activities" %>
<!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 id="Head1" runat="server">
<style type="text/css">
.floater
{
float:left;
border:solid 1px black;
padding:5px;
margin:5px;
}
</style>
<title>Activities</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater
id="Repeater1"
DataSourceId="srcActivities"
Runat="server">
<ItemTemplate>
<asp:HyperLink
id="HyperLink1"
Text='<%# Eval("Type") %>'
NavigateUrl='<%# Eval("Activities.aspx?id={0}") %>'
runat="server" />
<br />
</ItemTemplate>
</asp:Repeater>
<asp:AccessDataSource
id="srcActivities"
ConnectionString="Data Source=.\Access;
AttachDbFilename=|Desktop|WD364|Activities.accdb;
Integrated Security=True;User Instance=True"
SelectCommand="SELECT Id, Type FROM Activities"
Runat="server" />
</div>
</form>
</body>
</html>
The database is a simple MS Access Table (there is only one) with a few rows and two columns. One the ID and one the Type with the names of the activities. Any help would be greatly apprecitated
Try this
<asp:hyperlink id="hlxx" runat="server"
NavigateUrl='<%# "~/Activities.aspx?id="+Eval("Type") %>'
Target='<%# "_blank" %>'>Eval("Type")</asp:hyperlink>
Or see this
Send string with QueryString in Repeater Control in ASP.net
and below link have multiple answers
Link

Missing files from Ajax control Toolkit manifest error?`

Hello this is the first time I have used Ajax. I added ajax to my visual studio 2010 toolbox and pulled a calendar over my text box. When I run my site I get this error.
MissingManisfestResourceException
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly embedded or linked into assembly "AjaxControlToolkit" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Now it says I am missing ExtenderControlBase, Where can I get that?
My code of my calendar:
<asp:TextBox ID="txtBday" runat="server"
style="z-index: 1; left: 327px; top: 436px" Height="22px"></asp:TextBox><asp:CalendarExtender
ID="Birthday" runat="server"
onclientdateselectionchanged="CheckDateEalier" TargetControlID="txtBday"
PopupButtonID="btnBirth" PopupPosition="TopRight" >
</asp:CalendarExtender>
<asp:ImageButton ID="btnBirth" runat="server"
ImageUrl="~/images/calendaricon.jpg" />
It appears you forgot to reference the assembly at the top of your content file and need a script manager here is a working example hope it helps.
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox ID="TB" runat="server" />
<asp:CalendarExtender ID="C" runat="server" TargetControlID="TB">
</asp:CalendarExtender>
</form>
</body>
</html>

why don't recognize the textfield and the button like component's asp

i have in my code a table with a text field and a button on each cell. My problem it's that the button and the field are not recognized like System.Web.UI.WebControls.Button and System.Web.UI.WebControls.TextBox respectively. In fact recognize like buton are textfield html plain. I'm going to put my code so if anybody can see what i'm doing wrong.
Note: If i put this elemets out of the table work so i assumed that something wrong in the table
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MapaPrueba._Default" %>
<!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>Uso de google map</title>
<link href='/assets/css/styles.css' rel='stylesheet' type='text/css' />
</head>
<body>
<form id="form1" runat="server">
<asp:Panel runat="server" Height="1024" Width="768" style="text-align: center">
<div id="map-canvas" style="width: 700px; height: 500px" align="center"></div>
<asp:Table id="Table1" runat="server" CellPadding="10" GridLines="Both" HorizontalAlign="Center">
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Panel>
</form>
</body>
</html>
I would follow atrljoe's suggestion. Don't use an asp table, just use
<table>
<tr>
<td>
controls go here
</td>
<tr>
</table>
Tip: If you add the table first, switch in VS to Design View and using Ctrol + Alt + arrows you can add new rows and columns easily
You cant access the controls because your placing a Control (ASP Button & ASP TextBox) within a Control (ASP Table) ASP.NET Table. Every ASP.net page has a control tree, all the controls (HTML and server controls are in this control tree based on their position in page hierarchy). Thus since it is contained within the Control, the system is not picking it up. To gain access to this control you would need to use FindControl in your code behind.
As I had asked, If you really need to control this button and textbox, then consider changing to an HTML table. Otherwise when you reference these controls in your code behind you will need to use FindControl

Categories