Thursday, March 29, 2012
Newbie : Adding an onclick event to server control, prevents postback.??
I have a .net page that basically has two buttons on it. Each
button when
rendered by the server basically seem to have a type of "SUBMIT". What
i want is to be able to disable one of the buttons when a user clicks
on it and have the server process the operation and then renable it
went it's done.
I added the following piece of code to my Page_Load event.
MyButton.Attributes.Add("onclick", "this.disabled=true;");
This worked fine except that my event handler in the code-behind,
ExportButton_Click is not fired and so nothign happens except for the
button being disabled. Can someone give me detailed information on how
this can be done as I'm relatively new to C# , Javascript and .Net.
I was reading about the RegisterOnSubmit statement and such but it
did not
seem to work. What am I missing? What is an easy way to accomplish
this?
Code snippets/ links much appreaciated.
Thanksyes this is a problem.
one way around this is to hide the button instead.
if looks a bit stupid but you could have a disabled button which is hidden
until you click and hide the real button.
a bit mickey mouse but what can you do?
if you find a better way, please post it.
a
"Dr Deadpan" <drdeadpan@.yahoo.com> wrote in message
news:a944d23e.0311201528.32794f68@.posting.google.c om...
> Hi,
> I have a .net page that basically has two buttons on it. Each
> button when
> rendered by the server basically seem to have a type of "SUBMIT". What
> i want is to be able to disable one of the buttons when a user clicks
> on it and have the server process the operation and then renable it
> went it's done.
> I added the following piece of code to my Page_Load event.
> MyButton.Attributes.Add("onclick", "this.disabled=true;");
> This worked fine except that my event handler in the code-behind,
> ExportButton_Click is not fired and so nothign happens except for the
> button being disabled. Can someone give me detailed information on how
> this can be done as I'm relatively new to C# , Javascript and .Net.
> I was reading about the RegisterOnSubmit statement and such but it
> did not
> seem to work. What am I missing? What is an easy way to accomplish
> this?
> Code snippets/ links much appreaciated.
> Thanks
Instead of adding an "onClick" attribute to the button,
why not just disable it from the buttons click event?
ie. myButton.Enabled = False
I guess what you are trying to achieve is to prevent the
user from clicking the button more than once.
You should also make sure you have wired up your event
handlers for the button.
eg. protected WithEvents btnMyButton As Button
protected sub btnMyButton_Click() Handles btnMyButton.Click
end sub
This is VB code, but you need to make sure you declare
your button using 'WithEvent', and wire up the proper
event (using the 'Handles' statement) to the method that
will be handling the event.
It might also be a good idea to set the AutoEventWireup
directive in your .aspx page to False, otherwise your
event will fire twice.
Hope this helps
>--Original Message--
>Hi,
> I have a .net page that basically has two buttons on
it. Each
>button when
>rendered by the server basically seem to have a type
of "SUBMIT". What
>i want is to be able to disable one of the buttons when a
user clicks
>on it and have the server process the operation and then
renable it
>went it's done.
> I added the following piece of code to my Page_Load
event.
>MyButton.Attributes.Add("onclick", "this.disabled=true;");
> This worked fine except that my event handler in the
code-behind,
>ExportButton_Click is not fired and so nothign happens
except for the
>button being disabled. Can someone give me detailed
information on how
>this can be done as I'm relatively new to C# , Javascript
and .Net.
> I was reading about the RegisterOnSubmit statement and
such but it
>did not
>seem to work. What am I missing? What is an easy way to
accomplish
>this?
> Code snippets/ links much appreaciated.
>Thanks
>.
"Rory" <anonymous@.discussions.microsoft.com> wrote in message news:<069e01c3aff6$1699ce20$a401280a@.phx.gbl>...
> Instead of adding an "onClick" attribute to the button,
> why not just disable it from the buttons click event?
> ie. myButton.Enabled = False
I cannot do this as it won't work. What the above will do, is disable
the button once it gets bakc to the client. All the while while the
server is actually running the code in the event handler, the button
will remain Enabled and will become disabled once the code behind is
done - definitely not what I wnat. I read a post earlier on about
doing it an easier way somewhere.
Please, all you guru's , keep the comments coming..
DrD
Monday, March 26, 2012
Newbie Access Database Question
Database has 5 columns: Section, Author, Title, Link, Bibiography
Website:
Section
Author, Title (linked), Bibiography
...
Author...
Section
Author...
Make sense?
This would be very easy in asp, but I haven't quite gotten the grasp of .netSuggestion: Forget ASP. Yeah it stinks to start over, but it's easier that way.
the 'dot net way':
Grab the data into a data set. Check out theTutorials (linked above). There are also a ton of other sites out there for accessing data from a database with .NET. Search for '.NET + Access + DataSet'.
Once you have it in a DataSet object the rest is sooooo easy. Just setup a repeater object on the page. Then an 'item template' and define how you want each item to look like. Lastly add a seperator template if you want something between records. Finally in the code section do MyRepeater.DataSource = MyDataSet.Tables(0) *your data, then MyRepeater.DataBind() and you'll be all set. If you want tabular data without too crazy of formatting, check out the DataGrid. If you just want to list the results in columns you do the DataSource line from above (except you use a DataGrid object) and the DataBind method call. The rest is automagic.
If you need help with the data access, check out the Access forum in the Data Discussions section.
-Ryan
You can use a Repeater, DataList, or DataGrid for this purpose. This tutorial might be helpful:Binding to Data Display Controls. See also the Tutorials section of this site (in particularData Access and Customization). I think a DataList might suit your purposes pretty well, or a Repeater if you need more control (but also requires more coding).
Terri
thanks for the quick responces...
I looked up how to use the repeater control and it seems like this is what I'm looking for. Is the best way to group all of the same sections together to make an if statment? Is that legal within a repeater? Here's what a sample database looks like
General, Blah, Blah
General, Blah2...
Science, Blah3...
Science, Blah4...
I'd like it to:
General
blah
blah2
Science
blah3
blah4
Thanks for all your help
I think you want to put a Order By clause in your SQL Query.
Select Section, Author, Title, Link, Bibiography from MyDB
Order By Section, Author DESC
This will return
General, bob, bobs book, xxx, xxxx
General, sarah, sarahs book, xxx, xxxx
General, tim, tims book, xxx, xxxx
Science, joe, joes book, xxx, xxx
It first sorts Section alphabetically and then within all matching sections it then sorts on the author.
Saturday, March 24, 2012
Newbie here need some help..
Basically do you have any advice on how i should go about it
Thanks
Zim
This is possible there are 2 ways of doing so.
A) Create an administration section that has a few pages to modify the prices / items/ personel information or whatnot
B) Integrate a CMS (content management solution) that will modify the xml or html or aspx directly and save it.
If you are interested in B Telerik RAD has a nice set of controls , one of them being a cms solution. If you want a cost effective solution
get a good book on ado.net look at the update/delete/ insert and create a simple admin section with a login.
Good luck with your site.
Thursday, March 22, 2012
Newbie Membership question
I have a database that I want to basically place on the web. I have user information inside a table within this database. The database is an SQL Server DB. My question is how to use the membership and role features when a db with user info is already created. Are there any good examples of this out there? Thanks.
First off: there is a whole "Security" forum dedicated to membership and role talk
Secondly: what you are going to be after is a "Customer Membership Provider"
I also have a list of good security resources on ASP.NET 2.0 here:http://weblogs.asp.net/scottgu/archive/2006/02/24/438953.aspx
It includes a nice video that walksthrough how to setup a login system.
Hope this helps,
Scott
Friday, March 16, 2012
Newbie needs to edit communityserver.org site
Server software.
It doesn't sound too complicated. Basically, I need to move a list
summary control from the sidebar to the body of a page. I don't yet
have FTP access to the site's files.
I've got just enough experience with master pages and css to get me in
trouble, err, hack/experiment until get it right.
I'm very far from being a wiz with .NET apps, though. I'm concerned
that once I've created a new master page and added it to the system
I'll have to recompile the app? Not sure exactly how to do that using
FTP. Would I need to download the whole app, make my changes, compile,
then upload back to the production server? I really don't want to
break this site.
TIA,
ScottHello! Good Site! Thanks you! exzeutfgxhbxr