c# - KeyNotFoundException unhandled by user -
i trying retrieve query string value inside mainpage.xaml.cs , need access value accessing html id on different page(aspx). point if try access code querystring value not exist keynotfoundexception.
i have tried overcome problem doing following
htmldocument htmldoc = htmlpage.document; if (htmldoc.querystring["productcode"] != null) { productcode = htmldoc.querystring["productcode"].tostring(); } else { productcode = htmldoc.getelementbyid("vidweeklyfeature").getproperty("value").tostring(); }
but still same exception.
how can retrieve value based on condition value can accessed querystring or not?
(sorry being bit inarticulate)
you can use trygetvalue method rather use indexer.
it this:
htmldocument htmldoc = htmlpage.document; string productcode; if (!htmldoc.querystring.trygetvalue("productcode", out productcode)) { productcode = htmldoc.getelementbyid("vidweeklyfeature").getproperty("value").tostring(); }
Comments
Post a Comment