Change the text in ASP:LABEL

R

richard

I have a function Message_Show:

Public Sub Message_Show(ByVal sLabel As Label, ByVal sButton As Button,
ByVal sMessage As String, ByVal sButtonText As String)
If (IsPostBack) Then
sLabel.Text = sMessage
sLabel.Visible = True

sButton.Text = sButtonText
sButton.Enabled = False
End If
End Sub

I call this function in the SubmitBtn_Click

Message_Show(ITIN_Message, btnSubmit, "Retrieving data.... This may
take several seconds. Please be patient", "Retrieving")

The problem I'm having is this, it doesnt disable the button or show
the label until the datalist is populated. The SubmitBtn_Click function
does a DB query and populates a datalist. How can I get this to process
before the datalist is populated and shown?
 
A

Arthur Dent

The problem is that you want to process this immediately, client-side, while
the processing takes place server-side on the postback.
You can do this with javascript, something along the following lines in your
aspx markup code (as one example).
This should give you a starting point, and you can change around the
javascript function to do exactly what you want.

Example Follows :>

<head>
<script>
function doClientCode(msg){
document.getElementById('<%=lblMyLabel.ClientID %>').innerText =
msg;
document.getElementById('<%=btnMyButton.ClientID %>').disabled =
true;
}
</script>
</head>
<body>
..... some markup .........................
<asp:label id="lblMyLabel" runat="server" text="" />
<asp:button id="btnMyButton" runat="server"
onclientclick="javascript:return doClientCode('Show this message.');"
text="Click Me" />
..... some markup .........................
</body>

If you are feeling adventurous, you could play around with an AJAX
framework, but i cannot give any advice as to the best way to do it that
way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top