progress template in asp.net? - asp.net

in my web application i am uploading a video file. While uploading i want to give message to user wait video uploading can i use UpdateProgress can u give me a simple example. Thank you

Hi there here is a small example how you display a updateprogress on a background job:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
UpdateProgress control
Loading...
protected void UpdateButton_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}

Related

asp button click event

I am using C#.net for creating an aspx page (Visual Studio 2010).
I have copied most of the template code from online ( HTML ) but when I drop a button of asp and double click it, it doesn't redirect to the code behind page but, instead creates "onclick=btnSubmit_Click" event in the source code.
<asp:Button ID="btnSubmit" runat="server" Text="Submit" Height="30px"
Width="100px" **onclick="btnSubmit_Click"** />
Ideally it should go to the code behind page and allow event handling stuffs, I have no idea why this is happening.
My question is:
1. What do I do in order to get redirected like normal asp pages in Visual Studio
2. If possible, can someone explain what am I doing wrong here?
**I did get a way around it by using javascript
<script type="text/javascript" runat="server">
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
txtName.Text="btn submit clicked"
End Sub
please make sure that your <%Page directive has mentioned CodeBehind file.
i.e
something like this
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage/example.Master" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="Example.default" %>
this will be on the top of your aspx page
Please try with the below methods.
Method 1:
Based on what I found here: http://forums.asp.net/t/1229894.aspx/1
Right click on your solution explorer.
Add New Item -> Class File.
Name the file as the name of your aspx eg: Default.aspx.cs
When it asks you the file should be in app_code click "no".
In your aspx in page attribute add
AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default"
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
Similarly in your class file that you just added remove everything. Your class should look like this:
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Method 2: while adding new page please make sure the place code in separate file box is checked

I am creating a website in ASP.Net using MasterPage

I am creating a website in ASP.Net using MasterPage . I need Help for using different page title on each page .
eg: My Company : Home
and My Compant : offerings on my second page how to do using a MasterPage
Master
...
<title>
<asp:ContentPlaceHolder ID="TitleContentPlaceHolder" runat="server"></asp:ContentPlaceHolder>
</title>
...
Content
...
<asp:Content ContentPlaceHolderID="TitleContentPlaceHolder" runat="server" ID="TitleContent">
<asp:Literal runat="server" ID="TitleLabel"></asp:Literal>
</asp:Content>
...
Content codeBehind
protected void Page_Load(object sender, EventArgs e)
{
...
TitleLabel.Text = "Some title";
...
}
there is a section on your child page as follows
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
You can put anything in-between which you write in the head section.
<%# Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
here you can set the title in the page directive
or on the code behind
protected void Page_Load(object sender, EventArgs e)
{
Page.Title = "Master Page ";
}
You can use codebehind to give title to your content pages..
protected void Page_Load(object sender, EventArgs e)
{
Page.Title="your title";
}
This is the easiest way which you can follow..

ASP.NET button click event only works when on Top level master page

I have base.master (top-level), second.master (submaster). A button in the top-level master fires the click event fine, on a page which ues that one master, if its on page where the second.master is used, that button click event doesn't work.
No buttons that I place in the submaster work either, heres the code:
protected void afd(object sender, EventArgs e)
{
var a = "C";
}
<asp:Button runat="server" OnClick="afd" Text="huh" />
Base.master directive:
<%# Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="True" CodeBehind="Base.master.cs" Inherits="UmbracoWebsite.masterpages.Base" %>
Register.master directive:
<%# Master CodeBehind="~/masterpages/Register.master.cs" Inherits="UmbracoWebsite.masterpages.Register" Language="C#" MasterPageFile="~/masterpages/Base.master" AutoEventWireup="True" %>
By this it means you are wiring up button_click event manually and also you are missing button name so i would assume it as btn1
so you also need to provide the following line on Page_Load of Page_Init of the page where using it:
btn1.Click += new EventHandler(afd);
Hope this helps....

ASP.NET page with base class with dynamic master page not firing events

I am feeling that I have terribly wrong somewhere. I was working on a small asp.net app. I have some dynamic themes in the \theme folder and have implemented a page base class to load the master page on the fly. The master is having the ContentPlaceHolder like:
<asp:ContentPlaceHolder ID="cphBody" runat="server" />
Now I am adding pages that are derived from my base class and added the form elements. I know, Visual Studio has problem showing the page in the design mode. I have a dropdown box and wish to add the event of onselectedindexchange. But it is not working. the page is like this:
<%# Page Language="C#" AutoEventWireup="true" Inherits="trigon.web.Pages.MIS.JobStatus" Title="Job Status" AspCompat="true" CodeBehind="JobStatus.aspx.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphBody" runat="Server">
<div id="divError" runat="server" />
<asp:DropDownList runat="server" id="jobType" onselectedindexchange="On_jobTypeSelection_Change"></asp:DropDownList>
</asp:Content>
I have also tried adding the event on the code behind like:
protected void Page_Load(object sender, EventArgs e)
{
jobType.SelectedIndexChanged += new System.EventHandler(this.On_jobTypeSelection_Change);
if (!IsPostBack)
{
JobStatus_DA da = new JobStatus_DA();
jobType.DataSource = da.getJobTypes();
jobType.DataBind();
}
}
protected void On_jobTypeSelection_Change(Object sender, EventArgs e)
{
//do something here
}
Can anybody help?
Regards,
set AutoPostBack="true" on your dropdown

view state in asp.net

I can disable viewstate of each control, but not entire page.
Is there a way to disable viewstate in whole page?
Set Page.EnableViewState to false. This can be done either in the code-behind or in the page directive:
<%# Page EnableViewState="false" %>
You can also disable ViewState at the application level by setting the enableViewState attribute of the pages node to false in your web.config:
<pages enableViewState="false"/>
You can do it in the page declaration:
<%# Page EnableViewState='false' %>
private void Page_Init(object sender, System.EventArgs e)
{
this.EnableViewState = false;
}
You can set Page.EnableViewState="false"
But no matter what there will be some very small ViewState footprint on any .aspx page you create.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" EnableViewState="false" %>

Resources