ctl00$ContentPlaceHolder1$ in name of element asp.net html css

Lộc Đào 1 Reputation point
2022-12-06T12:05:09.13+00:00

I using name of input type file like this
267695-img1.png

but when i display on web it's changed to this
267801-img.png

how can I delete this ctl00$ContentPlaceHolder1$?

Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-12-06T16:47:07.893+00:00
    0 comments No comments

  2. Albert Kallal 5,586 Reputation points
    2022-12-06T19:13:02.25+00:00

    As noted, just add clientidmode="static".

    However, that will fix (result) in the id NOT be changed. I beyond often do this all the time when using jQuery selectors, and then to select your button or whatever then you can go

    myBtn = $('#posting')  
    

    And above will work. However, it NOT at all clear why you using/need "name". asp.net will munge that up for you, and clientidmode will NOT stop the .net system from changing the "name".

    But, you can force/fix/freeze this for "id" and a simple adding of clientidmode="static" will fix this issue.

    Hence this:

       <input class="contain_data" runat="server" type="file" name="posting"  
        id="posting"   
        clientidmode="static"  />  
    
    0 comments No comments

  3. Lan Huang-MSFT 30,186 Reputation points Microsoft External Staff
    2022-12-07T02:28:06.133+00:00

    Hi @Lộc Đào ,
    WebForms should only override the server control's ID,
    the runat="server" attribute, to indicate that it's a server control (rather than static HTML).
    I noticed that you already use <form method="post"> to send form data, you just need to remove runat="server".
    Of course, if you need runat="server", you can use the clientidmode="static" mentioned above.

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.