Calling JS in C #

-1

I'm working on WebForm with MasterPage, in this framework I'm not able to make modal call (js) in my C #.

Intheeventofthebutton(intheimageabove)withinamodalthesameasarefreshonthepageandkillsthemodal,followthecodebehindinC#:

protectedvoidbtnImportarGrade_Click(objectsender,EventArgse){strNomeArquivo=DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss");

    if (ValidarGrade(strNome, strTipo, strArquivo))
    {

    }
}

private bool ValidarGrade(string pstrNome, string pstrTipo, string pstrArquivo)
{  
    if (string.IsNullOrEmpty(pstrArquivo))
    {
        strMsg.Append("Selecione o Arquivo.");
    }
    else if (Path.GetExtension(pstrArquivo.ToLower()) != ".xls")
    {
        strMsg.Append("Arquivo inválido, só é permitido .xls.");
    }

    if (!string.IsNullOrEmpty(strMsg.ToString()))
    {
        ScriptManager.RegisterStartupScript(this, typeof(Page), Guid.NewGuid().ToString(), "$('#ModalNovaGrade').modal('show');", true);
        MessageBox.Alert(strMsg.ToString(), Page);
        return false;
    }
    return true;
}

Please complete the validation and refresh on the page. I need to keep it as modal open.

    
asked by anonymous 06.12.2017 / 18:03

1 answer

0

The page refreshes when a request to the server is made and the server controls the button through an AutoPostback = true property by default, which means that when they are clicked, a request to the server will be made. Set AutoPostback = false to the button you click.

    
06.12.2017 / 18:48