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

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -