Mixing a client-side/server-side event - DOTNET
This is a discussion on Mixing a client-side/server-side event - DOTNET ; I'm hoping this is a classic question, but the answer to it would help me
with a lot of things.
As you can see below, this code will never display the "Getting data...." text
in the lblCheck - because it ...
-
Mixing a client-side/server-side event
I'm hoping this is a classic question, but the answer to it would help me
with a lot of things.
As you can see below, this code will never display the "Getting data...." text
in the lblCheck - because it needs to do a round-trip to the server - first.
And when it gets back, my other routine will over-write the text as "34
records found"
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
Me.lblCheck.Text = "Getting data....."
SearchActionList()
End Sub
-
RE: Mixing a client-side/server-side event
Hi,
Add this code in form load or any other appropriate event:
btnSearch.Attributes.Add("onClick","return javascript
isplayLabelText();")
After adding this attribute, your asp:button (search button) will call the
javascript function first then submit the form if the function returns true,
otherwise it halts further execution if false is returned.
Code for javascript function would be something like this:
<script language="Javascript">
function DisplayLabelText()
{
document.getElementsByTagName('lblCkeck').innerText = 'Getting Data..';
return true;
}
</script>
Although i may not written exact syntax but i hope you have got an idea
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
"jonefer" wrote:
> I'm hoping this is a classic question, but the answer to it would help me
> with a lot of things.
>
> As you can see below, this code will never display the "Getting data...." text
> in the lblCheck - because it needs to do a round-trip to the server - first.
> And when it gets back, my other routine will over-write the text as "34
> records found"
>
> Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnSearch.Click
>
> Me.lblCheck.Text = "Getting data....."
> SearchActionList()
>
> End Sub
-
Re: Mixing a client-side/server-side event
"jonefer" <jonefer@discussions.microsoft.com> wrote in message
news:C535769E-A672-4749-A73B-F2D0A2BC4ADF@microsoft.com...
> I'm hoping this is a classic question, but the answer to it would help me
> with a lot of things.
>
> As you can see below, this code will never display the "Getting data...."
> text
> in the lblCheck - because it needs to do a round-trip to the server -
> first.
> And when it gets back, my other routine will over-write the text as "34
> records found"
>
> Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnSearch.Click
>
> Me.lblCheck.Text = "Getting data....."
> SearchActionList()
>
> End Sub
Don't hold me to it, but if you're using .Net 2.0, can't you use this?
Label1.Text = Server.HtmlEncode("Getting data.....")
I noticed it populated the label before it made the round trip when I pushed
the Submit button.
-
RE: Mixing a client-side/server-side event
Tried it and understand what it is supposed to do, but I will have to request
that you help me get the javascript exactly right, since I am unfamiliar with
what it needs exactly
the error I am recieving is: 'Error: expected ";"
and as you know, you ended all your lines with that.
"Manish Bafna" wrote:
> Hi,
> Add this code in form load or any other appropriate event:
> btnSearch.Attributes.Add("onClick","return javascript
isplayLabelText();")
> After adding this attribute, your asp:button (search button) will call the
> javascript function first then submit the form if the function returns true,
> otherwise it halts further execution if false is returned.
> Code for javascript function would be something like this:
> <script language="Javascript">
> function DisplayLabelText()
> {
> document.getElementsByTagName('lblCkeck').innerText = 'Getting Data..';
> return true;
> }
> </script>
> Although i may not written exact syntax but i hope you have got an idea
> --
> Hope this helps.
> Thanks and Regards.
> Manish Bafna.
> MCP and MCTS.
>
>
>
> "jonefer" wrote:
>
> > I'm hoping this is a classic question, but the answer to it would help me
> > with a lot of things.
> >
> > As you can see below, this code will never display the "Getting data...." text
> > in the lblCheck - because it needs to do a round-trip to the server - first.
> > And when it gets back, my other routine will over-write the text as "34
> > records found"
> >
> > Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles btnSearch.Click
> >
> > Me.lblCheck.Text = "Getting data....."
> > SearchActionList()
> >
> > End Sub
-
RE: Mixing a client-side/server-side event
Hi,
Below code is working perfectly well in my machine:
[1] Javascript Code:
<script language="Javascript">
function DisplayLabelText()
{
var obj = document.getElementById('lblCheck');
obj.innerText = 'Getting Data..' ;
return true;
}
</script>
[2]Code you will write in page load:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
btnSearch.Attributes.Add("onClick","javascript:return
DisplayLabelText();");
}
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
"jonefer" wrote:
> I'm hoping this is a classic question, but the answer to it would help me
> with a lot of things.
>
> As you can see below, this code will never display the "Getting data...." text
> in the lblCheck - because it needs to do a round-trip to the server - first.
> And when it gets back, my other routine will over-write the text as "34
> records found"
>
> Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnSearch.Click
>
> Me.lblCheck.Text = "Getting data....."
> SearchActionList()
>
> End Sub
-
RE: Mixing a client-side/server-side event
Ok, I implemented it, however --- it still doesn't do anything.
I read something about the property: OnClientClick
Here is a sample that actually does something:
<asp:Button ID="btnAlert" runat="server" OnClientClick="alert('Are you sure
you want to do this? (I dont do anything really.)');" Text="Client Alert"
UseSubmitBehavior="false" />
Can you help me modify it so that it just changes the text in lblCheck?
"Manish Bafna" wrote:
> Hi,
> Below code is working perfectly well in my machine:
> [1] Javascript Code:
> <script language="Javascript">
> function DisplayLabelText()
> {
> var obj = document.getElementById('lblCheck');
> obj.innerText = 'Getting Data..' ;
> return true;
> }
> </script>
> [2]Code you will write in page load:
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> btnSearch.Attributes.Add("onClick","javascript:return
> DisplayLabelText();");
>
> }
> --
> Hope this helps.
> Thanks and Regards.
> Manish Bafna.
> MCP and MCTS.
>
>
>
> "jonefer" wrote:
>
> > I'm hoping this is a classic question, but the answer to it would help me
> > with a lot of things.
> >
> > As you can see below, this code will never display the "Getting data...." text
> > in the lblCheck - because it needs to do a round-trip to the server - first.
> > And when it gets back, my other routine will over-write the text as "34
> > records found"
> >
> > Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles btnSearch.Click
> >
> > Me.lblCheck.Text = "Getting data....."
> > SearchActionList()
> >
> > End Sub
-
RE: Mixing a client-side/server-side event
Ok, these two pieces effectively work to make the label say "Getting Data"
However - Now the SearchActionList() function that I run the code-behind
file doesn't run anymore. Did the client-side scripting replace the
code-behind OnClick?
[1]
function doClientCode(msg){
document.getElementById('<%=lblCheck.ClientID %>').innerText = msg;
document.getElementById('<%=btnSearch.ClientID %>').disabled = true;
}
[2] Code on in the Asp: button tag
<asp:Button ID="btnSearch" runat="server" onclientclick="javascript:return
doClientCode('Getting data....');" Text="Search" />
"Manish Bafna" wrote:
> Hi,
> Below code is working perfectly well in my machine:
> [1] Javascript Code:
> <script language="Javascript">
> function DisplayLabelText()
> {
> var obj = document.getElementById('lblCheck');
> obj.innerText = 'Getting Data..' ;
> return true;
> }
> </script>
> [2]Code you will write in page load:
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> btnSearch.Attributes.Add("onClick","javascript:return
> DisplayLabelText();");
>
> }
> --
> Hope this helps.
> Thanks and Regards.
> Manish Bafna.
> MCP and MCTS.
>
>
>
> "jonefer" wrote:
>
> > I'm hoping this is a classic question, but the answer to it would help me
> > with a lot of things.
> >
> > As you can see below, this code will never display the "Getting data...." text
> > in the lblCheck - because it needs to do a round-trip to the server - first.
> > And when it gets back, my other routine will over-write the text as "34
> > records found"
> >
> > Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles btnSearch.Click
> >
> > Me.lblCheck.Text = "Getting data....."
> > SearchActionList()
> >
> > End Sub
-
RE: Mixing a client-side/server-side event
It works, but now the Code-Behind routine connected to the button doesn't work.
How can I make the client-side run as well as the
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
SearchActionList()
End Sub
They need to both work.
"Manish Bafna" wrote:
> Hi,
> Below code is working perfectly well in my machine:
> [1] Javascript Code:
> <script language="Javascript">
> function DisplayLabelText()
> {
> var obj = document.getElementById('lblCheck');
> obj.innerText = 'Getting Data..' ;
> return true;
> }
> </script>
> [2]Code you will write in page load:
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> btnSearch.Attributes.Add("onClick","javascript:return
> DisplayLabelText();");
>
> }
> --
> Hope this helps.
> Thanks and Regards.
> Manish Bafna.
> MCP and MCTS.
>
>
>
> "jonefer" wrote:
>
> > I'm hoping this is a classic question, but the answer to it would help me
> > with a lot of things.
> >
> > As you can see below, this code will never display the "Getting data...." text
> > in the lblCheck - because it needs to do a round-trip to the server - first.
> > And when it gets back, my other routine will over-write the text as "34
> > records found"
> >
> > Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles btnSearch.Click
> >
> > Me.lblCheck.Text = "Getting data....."
> > SearchActionList()
> >
> > End Sub
Similar Threads
-
By Application Development in forum Javascript
Replies: 5
Last Post: 06-29-2007, 11:14 AM
-
By Application Development in forum DOTNET
Replies: 1
Last Post: 10-13-2006, 04:42 PM
-
By Application Development in forum DOTNET
Replies: 1
Last Post: 04-06-2005, 01:41 AM
-
By Application Development in forum Object
Replies: 2
Last Post: 10-11-2003, 04:33 AM
-
By Application Development in forum Inetserver
Replies: 1
Last Post: 08-04-2003, 07:09 PM