How to send a special character to the view , Asp.net mvc?

Asked

Viewed 125 times

1

I have a situation where I would like to position the page in the same position as the container I was in before sending the Get?

Example :

<!-- ==== contato ==== -->
<div class="container" id="contato" name="contato">
    <div class="row">

            @Html.Partial("_PartialMensagens")
            @using (Html.BeginForm("CadastroContato", "Representante", FormMethod.Get))
            {
            <form>
                <div class="form-group">
                    <input type="text" class="form-control" id="ContatoNome" name="ContatoNome" required placeholder="Nome"><br />
                    <input type="text" class="form-control" id="Telefone" name="Telefone" required placeholder="Celular"><br />
                    <input type="text" class="form-control" id="ContatoCidade" name="ContatoCidade" required placeholder="Cidade  UF"><br>
                    <textarea rows="4" cols="30" name="Mensagem" id="Mensagem"  class="form-control" required placeholder="Mensagem..."></textarea>
                    <br>
                    <button type="submit" class="btn btn-success">Enviar</button>
                </div>
            </form>
            }
    </div><!-- row -->

</div><!-- container -->
<!-- ==== contato ==== -->

I would need to return this way : http://localhost:18568/Representative/Index/1#contact

With this example it does not work because it does not recognize the #

return RedirectToAction("index", "Representante", new { id = Session["IdPaginaUsuario"] + "^#contato" });
  • I guess you’ll have to change the # for &#35;

  • there is Urlencode ? for Asp.net mvc

  • What do you mean Urlencode?

  • http://www.w3schools.com/tags/ref_urlencode.asp

1 answer

0

Try to use # because the Backslash tells your framework that it is a text and not a character reserved by the language leaving so: "#contact" and just a note, you put a circumflex accent in your code at ^#contact and maybe that’s your problem, so I guess you won’t even need the backslash

return RedirectToAction("index", "Representante", new { id = Session["IdPaginaUsuario"] + "\#contato" });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.