开发者

WIth this Code I am getting IE page load error on the Left hand bottom of the screen

I have this code in my view..

<div>
<input type="button" value="Cancel" id="btnCancel" onclick="window.location.href='../Reviewer'" />&nbsp;<input type="submit" value="Save" id="btnSave" onclick="saveCreateHeader()"/><input type="button" style="margin-left:50px;" id="btnNextStep" value="Next Step"   onclick="window.location.href='../CostSharingQuestionsIndex/<%=Model.ProductTemplate开发者_高级运维ID %>')"/> 
</div>

due to this code I am getting a pageload error? is that something wrong with this? this is the Error I am getting in IE

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; AskTbF-ET/5.8.0.12304)
Timestamp: Fri, 8 Oct 2010 19:30:36 UTC


Message: Expected ';'
Line: 273
Char: 21
Code: 0
URI: http://localhost:25973/ProductTemplate/CreateHeaderIndex/42567


Message: Expected ';'
Line: 273
Char: 58
Code: 0
URI: http://localhost:25973/ProductTemplate/CreateHeaderIndex/42567


First, I would take an entirely different approach here, use anchors and style them as needed, but use their native <a href="url"> behavior, for example:

<a href="../CostSharingQuestionsIndex/<%=Model.ProductTemplateID %>">Next Step</a>

For the why it doesn't work: Your last onclick handler looks like this:

onclick="window.location.href='../CostSharingQuestionsIndex/<%=Model.ProductTemplateID %>')"

It's got an extra ) in the string, it should look like this:

onclick="window.location.href='../CostSharingQuestionsIndex/<%=Model.ProductTemplateID %>'"

With it, it's trying to parse...well, I'm not sure what it would think exactly, but it isn't pretty, hence the error you're seeing.


<input type="button" style="margin-left:50px;" id="btnNextStep" value="Next Step"   
onclick="window.location.href='../CostSharingQuestionsIndex/<%=Model.ProductTemplateID %>')"/>

I don't see why there is a closing bracket in that last onclick. That might be causing your error.


I would start by cleaning the markup and using proper elements to respect the HTML semantics.

<div>
    <!-- You want a redirect here so use anchor, eventually style it with CSS -->
    <%= Html.ActionLink("Cancel", "Reviewer", null, new { id = "btnCancel", @class = "btnCancel" }) %>

    <input type="submit" value="Save" id="btnSave" />

    <!-- You want a redirect here so use anchor, eventually style it with CSS -->
    <!-- Notice the usage of routes here to avoid hardcoding urls -->
    <%= Html.ActionLink("Next Step", "CostSharingQuestionsIndex", new { id = Model.ProductTemplateID }, new { id = "btnNextStep", @class = "btnNextStep" }) %>
</div>

And the last thing is this submit button. It seems that you are calling a javascript function which could be attached unobtrusively:

$(function() {
    $('#btnSave').click(function() {
        saveCreateHeader();
    });
});

Or as this is a submit button you could use directly the submit event of the form this button belongs to. If it doesn't belong to a form you shouldn't use a submit button.

All this is to say that if you are using ASP.NET MVC and jquery you could make better use of it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜