using classic asp code inside asp.net?

2019-09-17 13:52发布

问题:

I have a application that running both classic asp and asp net. inside the classic asp page, I have a combo box and depends on the selection of the combo box I need to do something inside my asp.net page. For instance, if inside my classic asp page, I have a combo box and inside the combo box; book is selected than when I enter a price for book as a zero inside my asp.net page I supposed to get an alert. Is there any way to do that?

asp.net code

 if (Convert.ToDecimal(Values["myBookPrice"]) == 0)
{
 //You cannot use 0 price for books!
}

回答1:

Let say that you have some input control on any page, html, asp what ever, with some parametre that you wish to pass to an asp.net page

if the input control have a name attribute like

<form method="post" action="thenewpage.aspx">
    <input name="nameOfInput" type="text" id="idofinput" />
    <input type="submit" name="btnGo" value="Create Box" id="btnGo" />
</form>

and you have a button that make post back to an asp.net page, then you get that parametre on asp.net side using the Request.Form and the name of the input control as:

Request.Form["nameOfInput"]

If you make a call the page with url parameter, you need to use some kind of javascript to dynamically create the URL string for the call.

The issue that you have here, is that the asp.net page will hit the validation of the page security because is not going to find the page validation informations he needed to secure the page.