c# - Dropdown value coming blank but still going in IF condition -


while submitting form, not selecting value dropdownlist , checking condition as

if (request.form["cmbnextuser"] != session["userid"].tostring() || request.form["cmbnextuser"] != null || request.form["cmbnextuser"] != "")         {             transfermail();         } 

so, while debugging value comes below.

img

the value coming blank still going in if condition

  1. condition 1 causing since comparing value

     request.form["cmbnextuser"] != session["userid"].tostring()  

    i.e "" != session["userid"].tostring() evaluated ture thats why it executing if block.

  2. change code this

    if (!string.isnullorempty(request.form["cmbnextuser"]) || request.form["cmbnextuser"] != session["userid"].tostring() ) {     transfermail(); } 

Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

angular - Angular2 Router: Cannot find primary outlet to load 'HomeComponent' -

qt - Microsoft FTP Service 451 The parameter is incorrect -