ด้วยเหตุผลบางประการ เมื่อฉันตั้งค่าคุณสมบัติสไตล์ TextAreaFor โดยเฉพาะคุณสมบัติ width มันไม่ทำงาน สิ่งที่ฉันหมายถึงคือความกว้างไม่เปลี่ยนแปลง และ Id ก็ไม่เปลี่ยนแปลงเช่นกัน:
@Html.TextAreaFor(model => model.AdminSetting.Style, new { htmlAttributes = new
{ @class = "form-control", @style = "width: 100%;", @id = "HelloWorld" } })
แต่หากฉันลบคำว่า htmlAttributes และเปลี่ยนเป็นคำนี้ มันก็จะทำงานได้ดี ฉันสงสัยจริงๆว่าทำไม:
@Html.TextAreaFor(model => model.AdminSetting.Style,
new { @class = "form-control", @style = "width: 100%;", @id = "HelloWorld" })
มีเหตุผลว่าทำไม TextAreaFor htmlAttributes ของฉันไม่ทำงานเว้นแต่ฉันจะลบการประกาศ htmlAttributes และประกาศเช่นนี้
new { @class = "form-control", @style = "width: 100%;", @id = "HelloWorld" })
แทนสิ่งนี้?
new { htmlAttributes = new
{ @class = "form-control", @style = "width: 100%;", @id = "HelloWorld" } })
ฉันได้ตรวจสอบเอกสารแล้ว และมั่นใจว่าฉันใช้โอเวอร์โหลดที่ถูกต้อง