how to change label with button in vb? - asp.net

so i want to have a button the changes the text of a label when i click it and it says page not available, but when i comment out the update panel it atleast shows up.
<form id="form1" runat="server">
<asp:ScriptManager ID="s1" runat = "server"></asp:ScriptManager>
<div>
<h1>UpDaTe PaNeL tEsT PaGe</h1>
start text : Hello <br />
updated text: World<br />
<hr />
<asp:UpdatePanel ID="p1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Update" OnClick="updateLabel" Height="29px" Width="110px"/> -->
Text: <asp:Label ID="Label1" runat="server" Text="hello"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
codebehind
Public Class aaaa
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Function updatelabel() As String
Label1.Text = "World"
End Function
End Class

The previous answer is correct. The handler for the Label Click event needs the sender as Object and the e as EventArgs parameters. If you do not put them, your updateLabeL() function will not be a valid match for the event handler.

You can remove the OnClick from the button and Try the classic method of handling events.
So your code will be... ( Sorry I'm posting it via app so it might not be in code view )
Protected Sub ChangeLabel(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.text = "TextGoesHere"
End Sub

Related

Print different document using different buttons

I am using the the Neodynamic SDK to print documents to the client side.
We will have 5 documents to print. I see how to print either 1 document or print all documents, but is there a way to print 1 document per button. I.e. button1 prints out doc1, button2 prints doc2, etc.
Here is what I've got so far
<script runat="server">
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
fileone()
filetwo()
End Sub
Public Sub fileone()
Dim fileToPrint As New PrintFile(Context.Server.MapPath("~/forms/xmlheader.txt"), "xmlheader.txt")
If (WebClientPrint.ProcessPrintJob(Request)) Then
'Create a ClientPrintJob
Dim cpj As New ClientPrintJob()
'set client printer, for multiple files use DefaultPrinter...
cpj.ClientPrinter = New DefaultPrinter()
'set files-printers group by using special formatting!!!
'Invoice.doc PRINT TO Printer1
cpj.PrintFile = fileToPrint
'send it...
cpj.SendToClient(Response)
End If
End Sub
Public Sub filetwo()
Dim fileToPrint As New PrintFile(Context.Server.MapPath("~/forms/ How To Recover Office Doc.pdf"), " How To Recover Office Doc.pdf")
If (WebClientPrint.ProcessPrintJob(Request)) Then
'Create a ClientPrintJob
Dim cpj As New ClientPrintJob()
'set client printer, for multiple files use DefaultPrinter...
cpj.ClientPrinter = New DefaultPrinter()
'set files-printers group by using special formatting!!!
'Invoice.doc PRINT TO Printer1
cpj.PrintFile = fileToPrint
'send it...
cpj.SendToClient(Response)
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
fileone()
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "printForm1", "printForm1();", True)
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
filetwo()
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "printForm2", "printForm2();", True)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to print multiple files to client printers from ASP.NET</title>
<script type="text/javascript">
function printForm1() {
jsWebClientPrint.print(fileone());
}
function printForm2() {
jsWebClientPrint.print(filetwo());
}
</script>
</head>
<body>
<%-- Store User's SessionId --%>
<input type="hidden" id="sid" name="sid" value="<%=Session.SessionID%>" />
<form id="form1" runat="server">
<h1>How to print multiple files to client printers from ASP.NET</h1>
Please change the source code to match your printer names and files to test it locally
<br /><br />
<%-- Add Reference to jQuery at Google CDN --%><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script><%-- Register the WebClientPrint script code --%><%=Neodynamic.SDK.Web.WebClientPrint.CreateScript()%>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"
Height="156px" Width="156px" />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" Height="156px" Width="156px"/>
<asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Button"
Height="156px" Width="156px"/>
<asp:Button ID="Button4" runat="server" onclick="Button4_Click" Text="Button"
Height="156px" Width="156px"/>
<asp:Button ID="Button5" runat="server" onclick="Button5_Click" Text="Button"
Height="156px" Width="156px"/>
</form>
</body>
</html>
I thought of changing filetwo() variable to clientprintjob cpj2...
What you need is to make a function called PrintDoc() that receives the path of the file to print as a parameter. The signature should look like this:
Private Sub PrintDoc(path as String)
End Sub
You only need this function once and no need for sub fileone() and sub filetwo() ... up to filefive(). You just need this one sub called PrintDoc(path as String)
Then you need 5 buttons, each with their own _Click() event and in that event handler you call the PrintDoc procedure by passing a different param everytime.
Hope this helps.
Good luck!

Button click event not fired after moving it to the asp:content

I just moved the button from html to the asp:content because I use master page :
<asp:content id="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ErrorMessage="CustomValidator"></asp:CustomValidator>
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<br />
<asp:Button ID="Button1" runat="server" Text="Upload" />
</div>
</asp:content>
The following code was working before I moved it, now the click event is not getting fired :
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
And it gave me an error (This error didn't occur before):
Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
So I added the below line of code :
Private WithEvents Button1 As Button
But still, the button1 is never fired.
Please kindly help me.
The ContentPlaceHolder is a different NamingContainer than the Page(it implements INamingContainer), so it's not initialized automatically from ASP.NET if you declare the variable Private WithEvents Button1 As Button.
You have to attach the event handler declaratively (or programmatically from codebehind):
<asp:Button ID="Button1" OnClick="Button1_Click" runat="server" Text="Upload" />
and remove the Handles clause, the method must now be at least Protected:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub

Handling events of usercontrols within listview

I have a simple usercontrol which raises an event on button click
Public Class UcPaymentCheque
Inherits System.Web.UI.UserControl
Public Event OnCancelClick()
Private Sub btnCancelPayment_Click(sender As Object, e As System.EventArgs) Handles btnCancelPayment.Click
RaiseEvent OnCancelClick()
End Sub
End Class
This usercontrol is used within a listview
<asp:ListView ID="lvwNonTpProducts" runat="server" ItemPlaceholderID="ItemPlaceholder">
<LayoutTemplate>
<asp:PlaceHolder ID="ItemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<TPCustomControl:UcPaymentCheque ID="UcTPPaymentCheque" runat="server" Visible="false" />
</ItemTemplate>
</asp:ListView>
which is databound on page load
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Else
BuildPage()
End If
End Sub
At what point should add the handler? I have fiddled with the ondatabound event like so;
Private Sub lvwNonTpProducts_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles lvwNonTpProducts.ItemDataBound
Dim UcTPPaymentCheque = DirectCast(e.Item.FindControl("UcTPPaymentCheque"), UcPaymentCheque)
AddHandler UcTPPaymentCheque.OnCancelClick, AddressOf OnCancelClick
End Sub
but this does not work and am guess at a databound issue???
You can check out my response to a similar question here: creating and listening for events
Essentially, you want a user control to raise its own event, like this:
Partial Class myControl
Inherits System.Web.UI.UserControl
Public Event MyEvent As EventHandler
'your button click event
Protected Sub bnt_click(ByVal sender As Object, ByVal e As EventArgs)
'do stuff
'now raise the event
RaiseEvent MyEvent (Me, New EventArgs)
end sub
end class
In this example, I raise the event when the user clicks a button within the user control. You can easily raise the event anywhere, such as when the control loads, using a timer, whatever.
Then, in the main page, you want to and an event handler to the user control, like this:
<mc:myControlrunat="server" ID="myControl1" OnMyEvent="myControl_MyEvent" />
Now, in the code behind, you can add the event, like this:
Protected Sub myControl_MyEvent(ByVal sender As Object, ByVal e As EventArgs)
'do stuff
end sub
You can add the handler in the declaration of the user control in the listview, using OnCancelClick, as follows:
<asp:ListView ID="lvwNonTpProducts" runat="server" ItemPlaceholderID="ItemPlaceholder">
<LayoutTemplate>
<asp:PlaceHolder ID="ItemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<TPCustomControl:UcPaymentCheque ID="UcTPPaymentCheque" runat="server" Visible="false" OnCancelClick="UcTPPaymentCheque_OnCancelClick" />
</ItemTemplate>
</asp:ListView>
Where UcTPPaymentCheque_OnCancelClick is the function you should use to handle the event, in the control that contains the listview.

ModalPopupExtender not displaying on button postback within updatepanel

I know this flavor of question has been asked multiple times, but I've spent hours sifting through answers that don't match or don't work and I'm at wits end.
Background: I have a situation where I want to evaluate a record to make sure it fits a specific set of criteria. If it fits the criteria, raise an alert message for confirmation from the user. I do not want to raise the popup unless the criteria matches.
Pseudocode of what I want to accomplish:
User enters information in multiple fields
User clicks "Save" (cmdUpdate)
within the "Save" click function it checks to see if the same record already exists
in the database (e.g. this is a duplicate).
If it's not a duplicate continue with the save function
If it's a duplicate prompt the user for confirmation to save the dup.
I can't get the popup to display before/after the postback. I've tried a hack workaround of setting a session value to maintain the state. The value tests positive in the prerender and does call the modalpopupextender.show but it never fires successfully to the screen. I'm not opposed to switching to a javascript solution if someone has a better method but I have to do the check for duplicates in the asp.net code behind.
Markup:
<asp:UpdatePanel ID="upMainContent" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="False" >
<ContentTemplate>
<asp:Label ID="lblDummy" runat="server" EnableViewState="false" Style="display: none;" />
<asp:Panel ID="pnlConfirmation" runat="server" Width="400px" Style="display: none;" CssClass="ModalPopupFront">
<div ID="Div1" runat="server" class="PopupHeader" style="width:400px;"> Duplicate Record</div>
<br />
<asp:Label ID="lblConfirmationMessage" runat="server" Text="This record has already exists.<br/> Are you sure you want to save a duplicate entry?"></asp:Label><br />
<br />
<div style="text-align:right;">
<asp:Button ID="btnSaveAnyway" runat="server" Text="Save" OnClick="btnSaveAnyway_Click" />
<asp:Button ID="btnCancelSave" runat="server" Text="Cancel" OnClick="btnCancelSave_Click" />
</div>
</asp:Panel>
<ajax:ModalPopupExtender ID="mpeSaveConfirmation" runat="server" Enabled="False"
TargetControlID="lblDummy" PopupControlID="pnlConfirmation"
BackgroundCssClass="modalBackground" DropShadow="true"
CancelControlID="btnCancelSave"
RepositionMode="RepositionOnWindowResizeAndScroll" PopupDragHandleControlID="pnlConfirmation" Drag="true">
</ajax:ModalPopupExtender>
<!-- all the input fields/misc content -->
<asp:Button id="cmdUpdate" runat="server" CausesValidation="true" OnClick="cmdUpdate_Click" Text="Save" ValidationGroup="vg1" ToolTip="Save the current record" TabIndex="102" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlStateId" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="ddlCountyId" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
Code behind:
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
'...
If GetSessionValue("HackWorkaround") Then
mpeSaveConfirmation.Enabled = True
mpeSaveConfirmation.Show()
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'...
If not Page.IsPostBack Then
SetSessionValue("HackWorkaround", False)
End if
'...
End Sub
Protected Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If tbOpTill.NewRecordIdenticalToLast() And tbOpRecord.NewRecordIdenticalToLast() Then
SetSessionValue("HackWorkaround", True)
Else
SetSessionValue("HackWorkaround", False)
SetSessionValue("LastOpRecordIDSaved", tbOpRecord.OpRecordId)
Dim isEdit As Boolean = ResetOpRecord("Till", tbOpTill)
SmartRedirect("Optill/oprecord_edit.aspx")
End If
End Sub
Protected Sub btnSaveAnyway_Click(ByVal sender As Object, ByVal e As System.EventArgs)
SetSessionValue("HackWorkaround", False)
mpeSaveConfirmation.Enabled = False
mpeSaveConfirmation.Hide()
'Duplicate record exists, but the customer wants to save anyway.
DoSave()
Dim isEdit As Boolean = ResetOpRecord("Till", tbOpTill)
SmartRedirect("Optill/oprecord_edit.aspx")
End Sub
Protected Sub btnCancelSave_Click(ByVal sender As Object, ByVal e As System.EventArgs)
SetSessionValue("HackWorkaround", False)
mpeSaveConfirmation.Enabled = False
mpeSaveConfirmation.Hide()
'do nothing and return to the screen.
End Sub
Your issue is here:
<ajax:ModalPopupExtender ID="mpeSaveConfirmation" runat="server" Enabled="False"
Protected Sub btnSaveAnyway_Click(ByVal sender As Object, ByVal e As System.EventArgs)
SetSessionValue("HackWorkaround", False)
**mpeSaveConfirmation.Enabled = False**
mpeSaveConfirmation.Hide()
Make it true in code behind. and sync hide show accordingly. Also i can see in your code at some places you are using Style="display:none". So if you want to display you need use HtmlStyleWriter.Display,"block". If you use Visible true false in that case it will not work. I mean to say, that where ever you are using visible true false, in codebehind you have to use similar. If you are using style, then in codebehind you have to use the same.

Adding PostBackTriggers and AsyncPostBackTriggers to UpdatePanel for dynamically-generated grandchild controls

I have a page with a ScriptManager, a generic HTML drop-down list (<select>), and an UpdatePanel. The UpdatePanel contains a PlaceHolder (for now). During Page_Load, a number of user controls are added to the PlaceHolder (really, it's several instances of the same user control). The number to add is not known until the page loads, so they do need to be loaded dynamically. The drop-down list is populated with the same number of menu items, and there is javascript on the page also (using jQuery) to show only one of the controls at a time depending on the state of the drop-down list.
Each user control has two buttons that should generate an asynchronous postback, a drop-down list that should generate an asynchronous postback on a change in selected value, and a button that should generate a synchronous postback. If I was not generating the controls dynamically, and if there was only one control, the structure would be something like:
<asp:UpdatePanel ID="myUpdatePanel" runat="server" UpdateMode="Conditional"
ChildrenAsTriggers="false">
<ContentTemplate>
<asp:TextBox ID="textBox1" runat="server" />
<asp:TextBox ID="textBox2" runat="server" />
<asp:Button ID="asyncButton1" runat="server" Text="Button1"
onclick="asyncButton1_Click" />
<asp:DropDownList ID="asyncDropDown" ruant="server" AutoPostBack="true"
OnSelectedIndexChanged="asyncDropDown_SelectedIndexChanged" />
<asp:Button ID="asyncButton2" runat="server" Text="Button2"
OnClick="asyncButton2_Click" />
<asp:Button ID="syncButton" runat="server" Text="SyncButton"
OnClick="syncButton_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="asyncButton1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="asyncButton2" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="asyncDropDown"
EventName="SelectedIndexChanged" />
<asp:PostBackTrigger ControlID="syncButton" />
</Triggers>
</asp:UpdatePanel>
Of course, all the controls inside the ContentTemplate would actually be part of each user control.
Adding the triggers on the server side does not seem to work because no ControlID seems to help the UpdatePanel find the relevant controls. I can use either the control's ID or the control's UniqueID, and it does not work, and I get an error along the lines of
A control with ID 'ctl00$ContentPlaceHolder1$ctl01$asyncButton1' could not be
found for the trigger in UpdatePanel 'myUpdatePanel'.
So, I wonder if I need to register the triggers in the client instead using ASP.NET Ajax. I found this page that basically explains how. However, I do not know how to get the EventName taken into consideration. The examples I have seen so far have merely been adding button clicks, but I don't know how to handle the SelectedIndexChanged event from the DropDownList.
Any help here? Are there examples out there I have missed? It doesn't help, of course, that the method in the link I gave appears to be "unofficial," so I don't see any MSDN documents on the subject.
Thanks!
My suggestion would be to pull all your controls inclusive this UpdatePanel out of this UpdatePanel into an UserControl. Define events in your usercontrol that are raised when the buttons are clicked or the Dropdown's selected index get changed. Handle these events in your page that holds the Placeholder(in a single UpdatePanel,conditional,without triggers). Call the Update-method of the main update panel manually if you add UserControls.
To clarify what i mean have a look at following example:
Main-page aspx:
<asp:UpdatePanel ID="Upd1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
Codebehind:
Private Property UserControlCount() As Int32
Get
If ViewState("UserControlCount") Is Nothing Then
ViewState("UserControlCount") = 1
End If
Return DirectCast(ViewState("UserControlCount"), Int32)
End Get
Set(ByVal value As Int32)
ViewState("UserControlCount") = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
recreateUserControls()
End Sub
Private Sub recreateUserControls()
For i As Int32 = 1 To Me.UserControlCount
Dim uc As DynamicControls = DirectCast(Me.LoadControl("DynamicControls.ascx"), DynamicControls)
uc.ID = "DynamicControls_" & i
Addhandlers(uc)
Me.PlaceHolder1.Controls.Add(uc)
Next
End Sub
Private Sub Addhandlers(ByVal uc As DynamicControls)
AddHandler uc.asyncButton1Clicked, AddressOf ucAsyncButton1Clicked
AddHandler uc.asyncButton2Clicked, AddressOf ucAsyncButton2Clicked
AddHandler uc.syncButtonClicked, AddressOf ucSyncButtonClicked
AddHandler uc.asyncDropDownSelectedIndexChanged, AddressOf ucAsyncDropDownSelectedIndexChanged
End Sub
Private Sub addUserControl()
Me.UserControlCount += 1
Dim uc As DynamicControls = DirectCast(Me.LoadControl("DynamicControls.ascx"), DynamicControls)
uc.ID = "DynamicControls_" & Me.UserControlCount
Addhandlers(uc)
Me.PlaceHolder1.Controls.Add(uc)
Upd1.Update()
End Sub
Private Sub ucAsyncButton1Clicked(ByVal sender As Object, ByVal e As EventArgs)
'only to demonstrate how to add control dynamically and update the UpdatePanel'
addUserControl()
Me.Upd1.Update()
End Sub
Private Sub ucAsyncButton2Clicked(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub ucSyncButtonClicked(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub ucAsyncDropDownSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
End Sub
ascx which holds your controls:
<%# Control Language="vb" AutoEventWireup="false" CodeBehind="DynamicControls.ascx.vb" Inherits="AJAXEnabledWebApplication1.DynamicControls" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:UpdatePanel ID="myUpdatePanel" runat="server" UpdateMode="Conditional"
ChildrenAsTriggers="false">
<ContentTemplate>
<asp:TextBox ID="textBox1" runat="server" />
<asp:TextBox ID="textBox2" runat="server" />
<asp:Button ID="asyncButton1" runat="server" Text="Button1" />
<asp:DropDownList ID="asyncDropDown" runat="server" AutoPostBack="true" />
<asp:Button ID="asyncButton2" runat="server" Text="Button2" />
<asp:Button ID="syncButton" runat="server" Text="SyncButton" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="asyncButton1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="asyncButton2" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="asyncDropDown" EventName="SelectedIndexChanged" />
<asp:PostBackTrigger ControlID="syncButton" />
</Triggers>
</asp:UpdatePanel>
Codebehind of UserControl:
Public Partial Class DynamicControls
Inherits System.Web.UI.UserControl
Public Event asyncButton1Clicked(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event asyncButton2Clicked(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event syncButtonClicked(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event asyncDropDownSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Private Sub asyncButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles asyncButton1.Click
RaiseEvent asyncButton1Clicked(sender, e)
End Sub
Private Sub asyncButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles asyncButton2.Click
RaiseEvent asyncButton2Clicked(sender, e)
End Sub
Private Sub syncButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles syncButton.Click
RaiseEvent syncButtonClicked(sender, e)
End Sub
Private Sub asyncDropDown_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles asyncDropDown.SelectedIndexChanged
RaiseEvent asyncDropDownSelectedIndexChanged(sender, e)
End Sub
End Class
On this way you won't have problems with ClientID's.
Addition:
If you need access to the controls of your UserControls in the event-handlers, use one of following two options:
cast the sender's NamingContainer to the userControl's type: Dim uc As DynamicControls = DirectCast(DirectCast(sender, Control).NamingContainer, DynamicControls)
replace all occurences of (ByVal sender As Object, ByVal e As System.EventArgs) with (uc as DynamicControls). On this way the reference of your UserControl is added to the event as parameter and you could access public properties of it from the page, f.e.:
dim txt1 as String = uc.Text1
If you have exposed a property Text1 in the UserControl:
Public Property Text1() As String
Get
Return textBox1.Text
End Get
Set(ByVal value As String)
textBox1.Text = value
End Set
End Property
The second option is the cleanest and most readable way.
Update:
According to your comment: you should place the UpdateProgress in the UserControl inside of the UpdatePanel that gets updated. Remember to set the AssociatedUpdatePanelID correctly. For example:
<asp:UpdatePanel ID="UdpForm" runat="server" UpdateMode="conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<asp:panel ID="FormPanel" runat="server">
<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="UdpForm" DisplayAfter="0" >
<ProgressTemplate>
<div class="progress">
<asp:Image ID="ImgProgress1" runat="server" ImageUrl="~/images/ajax-loader-arrows.gif" ToolTip="loading..." /> please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:FormView ID="FormView1" runat="server" DefaultMode="ReadOnly" >
<ItemTemplate></ItemTemplate>
<EditItemTemplate></EditItemTemplate>
<InsertItemTemplate></InsertItemTemplate>
<EmptyDataTemplate>
</EmptyDataTemplate>
<PagerTemplate >
</PagerTemplate>
</asp:FormView>
</asp:panel>
</contenttemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdContent" runat="server" UpdateMode="conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<asp:Panel ID="PnlMain" runat="server">
<asp:UpdateProgress ID="UpdateProgress2" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="UpdContent" DisplayAfter="0" >
<ProgressTemplate>
<div class="progress">
<asp:Image ID="ImgProgress1" runat="server" ImageUrl="~/images/ajax-loader-arrows.gif" ToolTip="loading..." /> please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
Content
</asp:Panel>
</ContentTemplate>
<Triggers ></Triggers>
</asp:UpdatePanel>

Resources