Я запускаю этот CodeBehind с c# в site.master.cs: < /p>
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "myFunction()", true);
< /code>
Этот код запускает этот скрипт в моем сайте.maste.aspx: < /p>
function myFunction() {
var x = document.getElementById("XXXX");
x.style.display = "none";
}
< /code>
Он должен скрыть этот элемент: < /p>
[*]Home
< /code>
Я вижу, что он скрывается для некоторых милисекундов, но страница обновляется сразу же, и она снова появляется.
Как предмет может скрыть после обновления страницы? After some hours of thinking and testing I got what I wanted with this:
I took the < li > out of the LoggedInTemplate so I can reach it from C# (I was unable to see the control from C# if it was inside the LoggedInTemplat, I dont know why ), well, then I just set visible-false with C# in Masterpage:
protected void Page_Init(object sender, EventArgs e)
{
if ((System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
{
//MessageBox.Show("Autenticado");
Aprobacionesbtn.Visible = true; //button in the navbar
Reportesmenu.Visible = true; //dropdown menu in the navbar
}
else if ((System.Web.HttpContext.Current.User == null))
{
//MessageBox.Show("No autenticado");
Aprobacionesbtn.Visible = false; //button in the navbar
Reportesmenu.Visible = false; //dropdown menu in the navbar
}
}
Подробнее здесь: https://stackoverflow.com/questions/755 ... ng-again-a
Скрыть элемент с JS от c# in site.master Элемент появляется снова после обновления страницы ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Скрыть элемент с JS от c# in site.master Элемент появляется снова после обновления страницы
Anonymous » » в форуме C# - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Pytest-django: класс модели site.models.Site не объявляет явную метку app_label
Anonymous » » в форуме Python - 0 Ответы
- 10 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Не удалось получить доступ к сценарию со страницы Master, но со страницы содержимого верно
Anonymous » » в форуме Html - 0 Ответы
- 7 Просмотры
-
Последнее сообщение Anonymous
-