|
I have a Save button on a web page.
I want to disable the button when clicked, so that the user does not click it more than once, as the serevr side code is being processed.
i disabled the button by calling a javascript function -
btnSave.Attributes.Add("onClick","return buttonDisabled();") ;
In the Javascript file i have -
function disableButton()
{
var btnSave = document.getElementById('btnSave') ;
btnSave.disabled = true ;
return true ;
}
since the button gets disabled my server side code(in C#) does not get executed.
thanks a lot for any kind of help
|
|
|
|
|
You need to call Page.GetPostBackEventReference(), and then put a call to __doPostBack() in your JavaScript function.
Here's how I did it in my test application:
private void Page_Load (Object sender, System.EventArgs e)
{
String clientScriptFunc = String.Format ("DisableButton_{0}", btnSubmit.ClientID);
if (!IsClientScriptBlockRegistered (clientScriptFunc))
{
RegisterClientScriptBlock (
clientScriptFunc,
GenerateDisableButtonScript (btnSubmit, clientScriptFunc)
);
}
btnSubmit.Attributes.Add ("onclick", String.Format ("return {0}();", clientScriptFunc));
}
private String GenerateDisableButtonScript (Button btn, String clientScriptFunc)
{
StringBuilder script = new StringBuilder ();
script.Append ("<script language=\"javascript\">\n");
script.AppendFormat ("function {0}() {{\n", clientScriptFunc);
script.AppendFormat (" var myButton = document.getElementById('{0}');\n", btn.ClientID);
script.Append (" myButton.disabled = true;\n");
script.AppendFormat (" {0};\n", Page.GetPostBackEventReference (btn));
script.Append (" return true;\n");
script.Append ("}\n");
script.Append ("</script>\n");
return script.ToString ();
}
GenerateDisableButtonScript() will output a JavaScript function like the following:
<script language="javascript">
function DisableButton_btnSubmit() {
var myButton = document.getElementById('btnSubmit');
myButton.disabled = true;
__doPostBack('btnSubmit','');
return true;
}
</script>
<div class='ForumSig'></div>
|
|
|
|
|
Hello,
I am attempting to create a page which will display data pulled from a database. What I would like to do, but not sure how to do it, is to have users input a Subject then the body of their post but when I pull up the page all relevant topics display the different posts in a Tree View. For example say a users starts a thread with topic "Pissed at you" I would like all responses or added blogs under this topic be displayed as a treeview. Pretty much the same as we see here on this page. I would also like to have all the topic collapsed with a plus sign then when clicked on with will expand to display the content of their blog. Any assistance will be greatly appreciated.
Greg
Coding makes the world go round!!!
|
|
|
|
|
What's the best way to use ASP.NET 2.0 and AJAX? I know there is ASP.NET AJAX but I have uninstalled it after trying it, I like hand coding mine better. My current environment is ASP.NET 2.0 with code in separate files all code is VB.NET, I'm using a master page to build a frame and I have a group of web controls created. I have my AJAX calling an aspx file, what I'm doing so far is working, but Visual Studio seems unhappy that my AJAX aspx file have no html, head, body or forms tags. Also, I'd like to make most of my controls AJAX enabled (and VS doesn't expect to see the html, head, etc. tags) but I can't directly access them (because they're .ascx files).
So the answers I'm looking for are, should I just continue on using .aspx files (and ignore errors), is there a better/more correct way to generate content to feed to JavaScript, is there a file extension that I can use as a web control or for AJAX as needed?
Thanks for any information you can provide.
|
|
|
|
|
RX Maverick wrote: I know there is ASP.NET AJAX
You mean ATLAS ? Yeah, that exists, and it's pretty simple to use, but expensive as well.
RX Maverick wrote: I have my AJAX calling an aspx file, what I'm doing so far is working, but Visual Studio seems unhappy that my AJAX aspx file have no html, head, body or forms tags
Just turn that validation off. Or, if it worries you, define a file extension like aspxa, set it up in IIS, and it will all be fine.
RX Maverick wrote: Also, I'd like to make most of my controls AJAX enabled (and VS doesn't expect to see the html, head, etc. tags) but I can't directly access them (because they're .ascx files).
What's the problem here ? I don't understand ?
RX Maverick wrote: should I just continue on using .aspx files (and ignore errors),
For the AJAX postback ? Yes, almost certainly.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I have been having some difficulty with the pageBaseType property in the pages element of the web.config file. The base page that I want every web page to use is MyPage.cs.
Here is my web.config code:
<pages
autoEventWireup="true"
enableEventValidation="false"
pageBaseType="MyNamespace.Components.MyPage, MyNamespace.Components"
styleSheetTheme="Default"
validateRequest="false" />
When creating a new web page, the class defined for that page has the following class header:
public partial class _default : System.Web.UI.Page
{
}
It extends from System.Web.UI.Page, but seeing that I have a base page, now how does everything work?? I surely can't remove System.Web.UI.Page then it will give me an error??
Please can someone help me with my confusion.
Regards,
ma se
|
|
|
|
|
I have no idea what the web.config stuff does. If I were you, I'd try to access a property on the new base class. If it works, the whole thing seems very nasty to me. If it doesn't, you need to change the base class.
I'd hope that the web.config entry means the compiler would enfore that the base class is set properly, not magically change it from what the code says, but I had no idea that was available in the web.config, so that's just my opinion.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Does it work if you use this syntax for pageBaseType :
pageBaseType="MyNamespace.Components.MyPage" instead of this:
pageBaseType="MyNamespace.Components.MyPage, MyNamespace.Components" ?
|
|
|
|
|
It's not the web.config that I am worried about, how does the class header look like of each web page seeing that it doesn't extend from the Page class??
|
|
|
|
|
Hello all,
I currently have an httpmodule that extracts various information regarding the response that is being sent to the client. One thing I want to implement is a count of how many external files (.js or .css) are being included in the page. I have a regex function for this, but the problem I'm having is I can't quite figure out how to access the markup that is being sent to the client. Here's most of what I have so far:
public class ResponseSizeHttpModule : IHttpModule
{
public void Init(HttpApplication application)
{
if (Convert.ToBoolean(ConfigurationManager.AppSettings["CheckResponseSize"]) == true)
{
application.BeginRequest += new EventHandler(this.AddFilter);
application.EndRequest += new EventHandler(this.ResponseMessage);
}
}
private void AddFilter(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
application.Response.Filter = new CounterClass(application.Response.Filter);
}
private void ResponseMessage(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
long lPageSize = application.Response.Filter.Length;
long lRespLimit = Convert.ToInt64(ConfigurationManager.AppSettings["ResponseLimitBytes"]);
if (lPageSize > lRespLimit)
{
string strResponse = "";
int intNumIncludes = CountIncludes(strResponse);
}
}
private int CountIncludes(string strResponse)
{
Regex reScripts = new Regex(".js|.css", RegexOptions.IgnoreCase);
return reScripts.Matches(strResponse).Count;
}
public void Dispose(){}
}
The bolded part is where I'd like to try to do this. I'm pretty new to httpmodules and the like so any suggestions on more effective methods are welcome, as would any other help.
Thanks in advance!
-------------------
abort, retry, fail?
|
|
|
|
|
There's a technique used in this article[^] that is similar to what you're describing. See if that is useful to you.
|
|
|
|
|
That did get me closer; I now have the functionality I need but it required another filter and module. Now I just need to get them to play nice together. Thanks!
-------------------
abort, retry, fail?
|
|
|
|
|
Hi
how can i use exsisting webservice in my appliation?
thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
|
yeah, i already added the reference. when i run my appliation, it's opening in Temuri.org something... but i am unable to use this in my page. we need to write any code in our web page?
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
don't take offense, but do you understand what a webservice is? Are you expecting something on your page without calling it?
|
|
|
|
|
not at all. i understand a bit about webservice.
i created one webservice. i add the web reference.
next i wrote this on my page:
public partial class mymathserviceclient : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
proxyMyMathService.MyMathService proxyMS = new proxyMyMathService.MyMathService();
double x = Convert.ToDouble(txtX.Text);
double y = Convert.ToDouble(txtY.Text);
double result = proxyMS.AddNumbers(x, y);
txtResult.Text = result.ToString();
}
}
stiil the webservice is directly running on the tempuri.org.
thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi.
I have a web application, which runs on the server. The application supposed to access folder on the Intranet (provided by user), grab some files and read them. The problem I have is the security. Some folders on the Intranet are not accessible. What happens is when user provides directory address to my application I cannot access the folder due to access denied error. How can I go around that? In my web.config file I have set <identity impersonate="true"> but still it doesn't work.
Thank you,
|
|
|
|
|
alexfromto wrote: grab some files
Does that mean they're being uploaded?
|
|
|
|
|
The files will be created by user in pdf format. I need to grab all of them in the directory (specified by user to my web application) and read files data into the database. The problem I get is when user specifies directory he has certain access. The application I have doesn't have that access and cannot even see the directory provided.
|
|
|
|
|
My Application State is throwing a null reference exception, when it shouldn't be. Any ideas??
|
|
|
|
|
Are you using IIS in production? If so, did you migrate the entire project? Did you add an application name to the VD?
|
|
|
|
|
Yes, and I'll add that the site worked before I added multi threading.
|
|
|
|
|
What is the exact error message.
|
|
|
|
|
I don't have it with me, but it's throwing a nullreferenceexception whenever it tries to access a value in the Application Session.
|
|
|
|
|