I have an ASP.NET 4.0 web application where users upload videos to the server. I have a FileUpload control and 2 DropDownLists.
The user first selects a video to be uploaded from the FileUploadcontrol after that s/he selects a category from DropDownList1 (category list). After the user selects a category, I fill the second DropDownList with subcategories.
When I select a file to upload, and select a category from the DropDownList, the page disconnects from the server after postback. If I do the same scenario without selecting a file to be uploaded, I succesfully fill the second combo.
Here is my code :
<tr>
<td style="text-align: left;" class="style9" colspan="2">
<asp:Label ID="Label1" runat="server" Text="Video" Width="80px"></asp:Label>
<asp:FileUpload ID="FileUploadVideo" runat="server" ViewStateMode="Enabled" />
</td>
<td style="text-align: left;" class="style4">
<asp:Label ID="Label3" runat="server" Text="Category" Width="80px"></asp:Label>
<br />
<asp:DropDownList ID="cmbCategory" runat="server" AutoPostBack="True" OnSelectedIndexChanged="cmbCategory_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td style="text-align: right;">
<asp:Label ID="Label6" runat="server" Text="Subcategory" Width="80px"></asp:Label>
<br />
<asp:DropDownList ID="cmbSubcategory" runat="server">
</asp:DropDownList>
</td>
</tr>
Any help would be appreciated.
Since you're uploading video, I imagine this is erroring out due to the file size. The default max file size for ASP.NET applications is 4MB. You can add something like this to the <system.web> section of your web.config to increase that deault:
<system.web>
<httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>
This allows, for instance, for a 20MB file to be uploaded.
For more information check out this article: Large file uploads in ASP.NET
Related
i have taken one panel control in asp.net in that having one text box control and one button control ,when i open design the text box and button are not visible,when i run this i can see in the controls in browser
<asp:Panel ID="Panel1" runat="server">
<td align="center" colspan="4">
<asp:Label ID="Label20" runat="server" Style="font-weight: 700" Text="search by phone number : " ></asp:Label><asp:TextBox ID="txtphno" CssClass="ip" runat="server" placeholder="Phone Number"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ForeColor="Red" ControlToValidate="txtphno" Font-Size="Large" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtphno" ForeColor="Red" runat="server" ErrorMessage="Only Numbers" ValidationExpression="\d+"></asp:RegularExpressionValidator>
<asp:Button ID="btnSearchphno" runat="server" CssClass="inputbtn" OnClick="btnSearchphno_Click" Style="font-weight: 700; height: 26px;" Text="search" />
</td>
</asp:Panel
this is the source code what i have written please help me . .
thanks
teja
Couple of points to get u started
1) Clear Your project solution and rebuild your project
2) Restart your Visual studio instance and open your project freshly
After you clear project and reopen visual studio, if problem still continue, try delete the designer and regenerate it.
I am having a bit of trouble with a dynamic asp.net FormView (within Insert.aspx.vb) in my ASP.NET LINQ to SQL Website. Here is the code for the FormView...
<asp:FormView runat="server" ID="FormView1" DataSourceID="DetailsDataSource" DefaultMode="Insert"
OnItemCommand="FormView1_ItemCommand" OnItemInserted="FormView1_ItemInserted" RenderOuterTable="false">
<InsertItemTemplate>
<table id="detailsTable" class="DDDetailsTable" cellpadding="6">
<asp:DynamicEntity runat="server" Mode="Insert" />
<tr class="td">
<td colspan="2">
<asp:LinkButton runat="server" CommandName="Insert" Text="Insert" />
<asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:FormView>
When this form is displayed in a browser, there are 5 user input controls, and two buttons (insert/cancel). But here in the code, I do not see any reference to the 5 user input controls, unless they are represented by this line of code...
<asp:DynamicEntity runat="server" Mode="Insert" />
First, am I correct in assuming that this line of code builds the user input controls dynamically?
And, my actual problem -- I need to set the Focus to the first of these input's upon page initialization. Basically when someone chooses to insert a new item and is sent to this page, I want them to be able to start typing right away, without the need to actually click in that textbox to begin. Any help would be greatly appreciated?
I was able to resolve my issue by adding a Search field via Code, and then using this in the Page_Load event...
If table.DisplayName = "Employees" Then
MultiSearchFieldSet.Visible = True
txbMultiColumnSearch.Focus()
I am using asp.net CreateUserWizard to create a portal web site. The interface pages like below:
In the last step, I have a link to a pdf file. What I want is by clicking it, a pdf file will be opened. However it failed, it always go to the first screen(login web page).
The corresponding code of the last step:
<asp:CompleteWizardStep runat="server" ID="CompleteWizardStep">
<ContentTemplate>
<table style="font-family: Verdana; font-size: 100%;">
<tr>
<td align="center" class="style5" style="color: White; background-color: #5D7B9D;
font-weight: bold;">
Complete
</td>
</tr>
<tr>
<td class="style1">
Your account request was successfully submitted. Please download the
form and return it. You shoud receive an email response within 3 business days.
Thank you.
</td>
</tr>
<tr>
<td align="right" class="style1">
<asp:Button ID="ContinueButton" runat="server" BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="Continue"
Font-Names="Verdana" ForeColor="#284775" Text="Download Form" ValidationGroup="CreateUserWizard1"
PostBackUrl="~/admin/DownloadFile.aspx" />
</td>
</tr>
</table>
</ContentTemplate>
You see the code doesn't work at all.
Also PostBackUrl="~/admin/DownloadFile.aspx" is also not working, it is also going to login page. I heard that we enable Javascript something. But how to change my code since it is not in the code behind.
Many thanks.
It seems the ~/Admin/DownloadFile.aspx is protected and the user has no permission to access this file or Admin location as a whole.
You can put your DownLoadFile.aspx in unrestricted area
I've connected to database, using data set .xsr now I wan't to extract all rows in my table. Here is my table structure :
Lastname
Address
zipcode
city
country
email
So here is one example of table row entry :
Danish Morten Olsen 58b 82341 Kobenhavn Denmark email#email.com
Now I'd like for someone to tell me how can I extract this info for all entries in the table in format :
<tr>
<td>Lastname</td>
<td>Address</td>
<td>zipcode</td>
<td>city</td>
<td>country</td>
<td>email</td>
</tr>
where of course one html table row represents one table row in database, I'm a newbie just two days ago installed necessary tools, database and started programming asp <% %>(asp noob yes, programming noob no) .. this is important so please answer if you can spare time .
thank you
Standard ASP.NET Webforms (which is what I guess you'll be using) doesn't give you total control over your HTML - you're not programming directly in HTML and markup, but against an abstracted "webform" model. E.g. you use and create server-side objects like data source (to grab your data), a gridview etc. - and the server control then really renders out the HTML to be sent back to the customer's browser.
So you might have a SQL data source to reach into your SQL Server table and grab the data:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TestConnectionString2 %>"
SelectCommand="SELECT [Lastname], [Address], [zipcode], [city],
[country], [email] FROM [Addresses]">
</asp:SqlDataSource>
and then hook that up to a data-bound ListView on your ASP.NET form:
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<span style="background-color: #E0FFFF;color: #333333;">Lastname:
<asp:Label ID="LastnameLabel" runat="server" Text='<%# Eval("Lastname") %>' />
<br />
Address: <asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' /><br />
zipcode: <asp:Label ID="zipcodeLabel" runat="server" Text='<%# Eval("zipcode") %>' /><br />
city: <asp:Label ID="cityLabel" runat="server" Text='<%# Eval("city") %>' /><br />
country: <asp:Label ID="countryLabel" runat="server" Text='<%# Eval("country") %>' /><br />
email: <asp:Label ID="emailLabel" runat="server" Text='<%# Eval("email") %>' />
<br /><br /></span>
</ItemTemplate>
<EmptyDataTemplate>
<span>No data was returned.</span>
</EmptyDataTemplate>
<LayoutTemplate>
<div ID="itemPlaceholderContainer" runat="server"
style="font-family: Verdana, Arial, Helvetica, sans-serif;">
<span ID="itemPlaceholder" runat="server" />
</div>
<div style="text-align: center;background-color: #5D7B9D;
font-family: Verdana, Arial, Helvetica, sans-serif;color:#FFFFFF;">
</div>
</LayoutTemplate>
</asp:ListView>
Check out the official ASP.NET website which has plenty of articles, tutorials, screen casts and demos on how to get started on ASP.NET webform development.
If you want total control over your markup, you should check out ASP.NET MVC which is a new concept for ASP.NET developers, but which might be a lot more along the lines of what you already know from PHP programming. Here, you do have total control over your HTML and every bit and byte being sent back to the browser.
Marc
Have a look at: http://www.learnasp.com/freebook/asp/dbsimple.aspx
If you've just started learning ASP, you should rather start having a look at ASP.NET.
I never use asp but I did same thing in JSP, I just came across the link
http://www.powerasp.com/content/database/using_select.asp
This would probably help your using asp.
Your post led me to believe you were coding in Classic ASP, as opposed to ASP.NET. I recommend that you get started by watching some of the videos over on asp.net/learn. Start with this one on how to get data out of the database using a DataSet and Gridview by creating a data access layer (DAL) in your app. Optionally, you could read the HTML version of the tutorial.
When using asp:login, asp:forgotpassword and asp:createuserwizard controls within an ascx. (e.g registration.ascx) it can't find e.g UserName, even though it exists within LayoutTemplate. Any idea how to fix this?
If you open smart tag for control in design mode,you shall see that there are steps that can be convertible to templates for customization.
CreateUserWizard http://img197.imageshack.us/img197/3823/7d4df5a594a1abdb8fdc8f1.png
For CreateUserWizard , press Customize Create User Step and you will observe that,control is converted into a table template which you can see how controls named i.e. UserName,Password...
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep runat="server" ID="CreateUserWizardStep1">
<ContentTemplate>
<table border="0">
<tr>
<td align="center" colspan="2">
Sign Up for Your New Account</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
.......
Also know that If you wish to find control from inner templates , you must look for templates with FindControl method to reach the control you desire.
To Find UserName Control in above code,use
CreateUserWizardStep1.TemplateControl.FindControl("UserName") as TextBox
Hope this helps to solve your problem