473,545 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Attribute to BUTTON postback?

I am using a javascript WYSIWYG text editor for our CMS. To grab the proper
content we need to add a javacsript call to the form:

Form1.Attribute s.Add("onSubmit ", "myOnSubmitEven tHandler();")

That works fine.

However, we also have some dropDownLists that trigger a postback. If we
change these, I still need to update the text editor, so I added attributes
to them:

ddl_customConte nt.Attributes.A dd("onChange", "myOnSubmitEven tHandler();")
ddl_permissions _primaryCategor y.Attributes.Ad d("onChange",
"myOnSubmitEven tHandler();")

Again, that's working just fine.

The catch...I now have a few additional Buttons that trigger postbacks.
However, I can't figure out how to apply the same attribute to these
particular functions. They seem to ignore the 'onSubmit' attribute of the
form. Does that make sense?

I tried adding an onClick event, but that, too, doesn't seem to behave the
same way as the onChange event.

Thoughts?

-Darrel
Apr 5 '06 #1
2 5930
the form onsubmit is only called if the browser posts (say from enter or
submit button). if javascript does the postback (form.submit()) as done by
the autopostback controls then it won't fire. this is why you need add to
the dropdown.

generally asp:button are rendered as a submit, and will call the onsubmit.
they have a onclick event that fires before the postback. view source to see
if your onclick attributes are rendered correctly

-- bruce (sqlwork.com)

"darrel" <no*****@nowher e.com> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
I am using a javascript WYSIWYG text editor for our CMS. To grab the proper
content we need to add a javacsript call to the form:

Form1.Attribute s.Add("onSubmit ", "myOnSubmitEven tHandler();")

That works fine.

However, we also have some dropDownLists that trigger a postback. If we
change these, I still need to update the text editor, so I added
attributes to them:

ddl_customConte nt.Attributes.A dd("onChange", "myOnSubmitEven tHandler();")
ddl_permissions _primaryCategor y.Attributes.Ad d("onChange",
"myOnSubmitEven tHandler();")

Again, that's working just fine.

The catch...I now have a few additional Buttons that trigger postbacks.
However, I can't figure out how to apply the same attribute to these
particular functions. They seem to ignore the 'onSubmit' attribute of the
form. Does that make sense?

I tried adding an onClick event, but that, too, doesn't seem to behave the
same way as the onChange event.

Thoughts?

-Darrel

Apr 5 '06 #2
generally asp:button are rendered as a submit, and will call the onsubmit.
they have a onclick event that fires before the postback. view source to
see if your onclick attributes are rendered correctly


After MUCH digging, I finally discovered the issue wasn't with the onClick
at all.

If anyone cares, the issue is that the javascript was grabbing data from an
form field that was sometimes set to DISPLAY: hidden in the CSS. Apparently
javascript can't grab that. ;o)

So, instead of hiding it via css, I know move it off-screen via css, where
javascript CAN 'see' it.

Less accessible, but seems to work.

-Darrel
Apr 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
39754
by: Michelle | last post by:
I have a div that is initially empty. Clicking on a button will add some text boxes and other controls so the user can add additional records. In IE all works fine but in Netscape 7.0 when I add another "record" the values for all previous controls within the div are wiped out. In the javascript function where I add on to the html in the...
4
5461
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last...
4
5575
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer postback. I.e. the button does go disabled, but the form does not invoke submit() method. Of course, it does work fine without this property. Clues?
3
1377
by: Robert Bull | last post by:
I am trying to add a radio button at runtime in an asp.net web form but I keep getting the error message "type 'RadioButton' must be placed inside a form tag with runat=server". I use the following code: Dim rbYes As New RadioButton() dim sStyle as string sStyle = "POSITION:absolute; TOP: 250px; LEFT: 10px" rbYes.Attributes.Add("style",...
0
1247
by: sonic | last post by:
hello, I have this custom datagrid control, that inherits from DataGrid. In addition to datagrid, I am adding a "status" table under it, and another html button, which will trigger a new row. My problem is that the events associated with the custom button do not trigger every time. I am adding my button as private global control inside...
11
1563
by: Neo Geshel | last post by:
Greetings. Hopefully someone will be able to untie this Gordian Knot I have found myself bound up in. I am trying to add a submit button dynamically to a PlaceHolder. This button will help update a particular entry in a database. The button is added as thus: Sub LoadIntro() ...additional content that is dynamically loaded as well: a...
6
1584
by: Totto | last post by:
Hi, Anyone know the best solution to dynamically add buttons to a asp 2.0 page using data from Sql server? Are there any contols suitable for this or is it best to iterate the dataset and dynamicaly add buttons in the asp page? Totto
3
2113
by: Bart Van Hemelen | last post by:
I'm working on a project where the user of a site will receive custom content, depending on a set of parameters. The content will all be contained in UserControls (.ascx), that will be used as webparts on a page. We need to add the webparts dynamically to the site, depending on the status of the user: this involves a personalisation of a...
2
15049
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have been able to find the cause of the problem, and will describe it here first textually and then through a code example. The purpose of what I am...
0
7396
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7751
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5323
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
700
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.