Click here to Skip to main content
15,946,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one,
In a page there are 1 textbox and 1 tinyMCE for reach text box. At first I used asp requirement validation for both of that, there was a problem for that though that tinyMCE contains some value it gave the validation errors and sometimes the validation for textbox was not also working.

So, I changed that one and put the code in .cs file. like if (txtMessageContent.Value == " ") it will give an error message please enter your text. txtMessageContent is tinyMCE.

Now after writing message when I click on submit button for multiple times it posts the message for multiple times, but I need to send it once.

I used the javascript to disable the button but the problem is Button disables if it comes into the first else loop or second else loop in the code given below. That is also not desirable.

Any idea please.

MIDL
if (txtMessageContent.Value != "")
{
    if (txtMessageSubject.Text != "")
    {
        //Codes
    }
    else
    {
        lblErrorMessage.Text = "Please type subject";
    }
}
else
{
    lblErrorMessage.Text = "Please type your message.";
}
Posted
Updated 26-Oct-10 23:18pm
v2
Comments
Sandeep Mewara 27-Oct-10 5:43am    
1. What is tinyMCE?
2. Windows or Web app you are talking of?
arindamrudra 27-Oct-10 5:47am    
1. tinyMCE is a kind of rich text box. Its a kind of HTML control. We need to write scripts for that.
2. Web application.

Well, something similar to other answer but a little normal workflow.

Just tie a OnClientClick of the button to a JavaScript method. Let say, DisableMe();
JavaScript
// JS method
function DisableMe()
{
  btnSubmit.disabled = true;
}

And now, on server side, let the btnSumit code execute. Once all done, put the last line as btnSubmit.Enable = true;

This was, the moment you click the submit button, it wil get disabled and once all the operation defined in the submit button finishes on server side, the button gets enabled back.
 
Share this answer
 
Comments
arindamrudra 27-Oct-10 7:44am    
I have been directed to use the RPG pattern, but I dont know this. Can you please send any good example link for that.
Sandeep Mewara 27-Oct-10 7:45am    
Here you go: http://www.google.co.in/search?q=RPG+pattern&rls=com.microsoft:en-gb&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1&redir_esc=&ei=sxDITLjyBc2PcaKcoLIF
You should put it in a function and call it using
setTimeout()<br />

Like:
function submitClick()
{
  btnSubmit.enabled = false;
  setTimeout('doSubmit();', 50);
}

function doSubmit()
{
  // Your submit code
}


This way you give the browser some time to update the screen and to actually disable the button.

Good luck!
 
Share this answer
 
Comments
arindamrudra 27-Oct-10 7:44am    
I have been directed to use the RPG pattern, but I dont know this. Can you please send any good example link for that.

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