Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,

In my web page I hav 2 javascript function
1. fillVC (to hide div)
2. showDIV (to display div)

I want to call two different javascript function on button click in a sequence
1. fillVC
2. showDiv

I tried following:
protected void btnSearch_Click(object sender, EventArgs e)
   {
       this.GVDatabind();
       ClientScript.RegisterStartupScript(typeof(Page), "Javascript", "fillVC();", true);
       ClientScript.RegisterStartupScript(typeof(Page), "Javascript", "showDIV();", true);
   }


but problem is showDIV gets called before fillVC.

I have written in script:
<script>
     function showDIV()
     {}
     function fillVC()
     {}
</script>


Does the sequence of writing the function plays role in call of function??

Any idea how to achieve this?
Posted
Updated 20-Jun-12 1:51am
v3

Try this
C#
ClientScript.RegisterStartupScript(GetType(),"Open","Function Name",true);
 
Share this answer
 
Comments
dhage.prashant01 20-Jun-12 7:18am    
problem is that
i have two function
1. fillVC (i hide div)
2. showDIV (i display div)

I call this method as given question
Problem: div get visible and hidden in few seconds on button click
Why don't you put that code in Front-End inside onClientClick.. you can include as many as functions there.
have a look at example below

ASP.NET
<asp:button id="btnSubmit" text="Add Record" runat="server" tooltip="Click to Submit Filled Date" onclick="btnSubmit_Click" onclientclick="return ValidateEmail();CheckAge();ValidateForm(); " xmlns:asp="#unknown" />
 
Share this answer
 
v2
Comments
dhage.prashant01 20-Jun-12 7:31am    
problem is that i have two function
1. fillVC (i hide div)
2. showDIV (i display div)
I call this method as given question

Problem: div get visible and hidden in few seconds on button click

Any idea how to do it??
Since javascript functions run in parallel fashion. fillVC() and showDIV() runs in parallel.

In fillVC(), i used to hide div at the end but before that execution of statements in showDIV() ends.

So div used to get hide.

Solution:
I have put the code to hide the div on the first line in function and now the div is getting displayed as per the function call.

Thanks for your support friends.

Hope this helps the needy :)
 
Share this answer
 
HTML
<input type="button" id="Button1" onclick="javascript:if(IsValidEmail()) insert();" value="Add">
function IsValidEmail()
{

var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
var email=document.getElementById('txtEmail').value;

var matchArray = email.match(emailPat);

if (matchArray == null)

{

    return false;

}

else

{

   return true;

}
}


i hope this helps you..
 
Share this answer
 
v2
Comments
fjdiewornncalwe 4-Apr-13 15:28pm    
Plagiarized from here

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900