Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Page breaking when using Javascript to click a button

Posted on 2012-04-03
5
Medium Priority
?
246 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 22

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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
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…
Suggested Courses

971 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