I'm trying to read a class that is added by Javascript
on a click event, in ASP.NET
server side code but it still shows only those class which were add by server while initialization.
Here's the sreenshot of HTML element.
Here is what ASP.NET code is reading.
I'v even tried reading it like string css = imgThumbnail.Attrinutes["class"].ToString();
but it still returns the same.
I want to read that 'border-10' class on code behind.
您必须改用HiddenFileds
或隐藏的TextBox
。
Yeah, like Mahdi said, you need to use hidden fields. So make hidden field, Example:
<input type="hidden" id="Yourstylesheetinfo" asp-for="Yoursheetinfo" />
Then, set value to that field via JS:
var YourElement = document.getElementById(`YourElementsID`);
var style = window.getComputedStyle(YourElement);
//if you looking for border
var property = style.getPropertyValue('border');
//Lastly set value to hidden input
document.getElementById(`Yourstylesheetinfo`).value = property;
//maybe you'll need to use .toString() on property ? on line above this..
Something like this maybe.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.