1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

[Q] set <option> attribute to 'select' based on condition

Discussion in 'C#' started by twoclicks, Jul 10, 2013.

  1. #1
    Hello everyone,

    I'm totally new to C# .NET and i was trying to set the html <option value="condition1"> attribute to "selected" based on the value match the if statement condition that i wrote:

    Example Code:
    <option value="VIC" <%# if(AdorRec.FieldValue("state", Container) == 'VIC') { Console.WriteLine('selected'); } %>>Victoria</option>
    Code (markup):
    and when i run the script it doesn't work. Could someone please give me a bit of advices?
    Thank you
    twoclicks, Jul 10, 2013 IP
  2. seotraining

    seotraining Active Member

    Likes Received:
    Best Answers:
    Trophy Points:
    If you are using asp.net using c# then you can set the condition using dropdownlist why are you using <option> of html if you are using c# then bind it from table and you can set the query in the coding of c# page.
    seotraining, Sep 29, 2013 IP
    grandseo likes this.