Solved

Page breaking when using Javascript to click a button

Posted on 2012-04-03
5
220 Views
Last Modified: 2012-04-08
On my page I have the user enter a string into a field.  From this field I run some code behind to check for multiple matches.  If true, I display a table of each of these options.  If they click a row in the column I have javascript that will grab the unique id, put it into the field they initially entered a number into, and auto click the same button for them.  When I do this the page breaks (nothing on the page functions at all).  If I write the number from the table down, reload the page and enter it manually, the page functions correctly.  

The javascript seems to be breaking my page somehow.  Any help understanding what would cause the page to break would be very helpful. Thank You.

Javascript
        function pullDeal(DealNumber) {
            var txt = $find('ctl00_maincontentholder_txtDealNumber');
            var btn = document.getElementById('ctl00_maincontentholder_btnDownloadDeal');
            var pnl = document.getElementById('ctl00_maincontentholder_pnlDealSelection');
            txt.set_value(DealNumber);
            txt.disabled = true;
            pnl.style.display = "none";
            btn.click();
        }

Open in new window


AjaxSetting (for updating the table)
<telerik:AjaxSetting AjaxControlID="ibtnDownload">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnlDealSelection" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </telerik:AjaxSetting>

Open in new window


Onclick for the row of the table
onclick="pullDeal('<%#Eval("DealNumber")%>'); return false;"

Open in new window

0
Comment
Question by:huston8481
  • 4
5 Comments
 
LVL 21

Expert Comment

by:Kim Walker
ID: 37801038
Do you have this posted somewhere so we can see what errors are being generated?
0
 

Author Comment

by:huston8481
ID: 37801073
No, it is on a private site.  I am unable to find the error, because it is being hidden behind ajax.  I am in the process of disabling the update panels to see the error.  Any help on this would be appreciated.
0
 

Author Comment

by:huston8481
ID: 37801129
This is the exception I received.  If i take out my debugging code in the code behind it works fine.

I was able to fix it by simply removing the offending line of code which writes information to me in a text box.  But I am interested in finding out why it would do this, for education purposes.

Exception
Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (ctl00$maincontentholder$salvotest="...e entered.<br /> Please select...").

Open in new window


Code Behind that was breaking it, which is odd because it should not run the second time the button is clicked.
salvotest.Text += "More than one deal was found for the Stock Number you have entered.<br /> Please select the correct deal to continue."

Open in new window

0
 

Accepted Solution

by:
huston8481 earned 0 total points
ID: 37801164
After further inspection it seems that having a "<br>" go to my text box is scaring it into think I'm "injecting" some code into my page.

Annoying little problems...
0
 

Author Closing Comment

by:huston8481
ID: 37820846
With the help of a co-worker and myself the problem was solved by removing the <br/> tag from the textbox output.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now