【问题标题】:how to change url in asp.net c#?如何更改asp.net c#中的url?
【发布时间】:2017-05-30 21:56:58
【问题描述】:

我正在尝试在我的 ASP.net 应用程序中创建搜索选项,以根据位置检查医生详细信息。如果我尝试以下代码,则只显示主页。 http:www.example.com/doctordetails.aspx?ID=1/DoctorName=IVIN.

我希望根据位置更改 URL。预期 URL 示例:http://www.example.com/doctordetails/chennai/doctors/saidapet

我是这项技术的新手。

 <asp:Repeater ID="rptCustomers" runat="server">
                                <HeaderTemplate>
                                   <div class="tg-view tg-grid-view">
                                <div class="row">

                                </HeaderTemplate>
                                <ItemTemplate>
                                    <article class="tg-doctor-profile">
                                            <div class="tg-box">
                                       <figure class="tg-docprofile-img"><a href="#"><img src="images/doctors/img-13.jpg" alt="image description"></a></figure>
                                                    <span class="tg-featuredicon"><em class="fa fa-bolt"></em></span>
                                                <div class="tg-docprofile-content">
                                                    <div class="tg-heading-border tg-small">
                                                        <h3><a href="<%# String.Format("doctordetails.aspx?ID={0}/DoctorName={1}", Eval("DoctorID"),Eval("DoctorName"))   %>"><asp:Label ID="lblName" runat="server" Text='<%# Eval("DoctorName") %>' /></a></h3>
                                                    </div>
                                                    <div class="tg-description">
                                                        <p>Lorem ipsum dolor sit amet, consectetur aicing elit, sed do eiusmod tempor incididunt.</p>
                                                    </div>
                                                    <ul class="tg-doccontactinfo">
                                                        <li>
                                                            <i class="fa fa-map-marker"></i>
                                                            <address><asp:Label ID="lbladdress" runat="server" Text='<%# Eval("DocAddress1") %>' /></address>
                                                        </li>
                                                        <li>
                                                            <i class="fa fa-phone"></i>
                                                            <span><asp:Label ID="lblMobile" runat="server" Text='<%# Eval("Mobile") %>' /></address></span>
                                                        </li>
                                                        <li>
                                                            <i class="fa fa-envelope-o"></i>
                                                            <a ><asp:Label ID="lblmail" runat="server" Text='<%# Eval("Email") %>' /></a>
                                                        </li>
                                                        <li>
                                                            <i class="fa fa-fax"></i>
                                                            <span>+44 235 856843</span>
                                                        </li>
                                                    </ul>
                                                </div>
                                                </div>
                                    </article>
                                </ItemTemplate>
                                <FooterTemplate>

                                    </div>
                                    </div>
                                </FooterTemplate>
                            </asp:Repeater>

【问题讨论】:

  • 有点不清楚你在问什么,你能说清楚你的实际要求吗?
  • 我想要这个网址practo.com/chennai/doctors/saidapet@un-lucky
  • 使用 & 指定多个查询字符串。示例:ID=1&amp;DoctorName=IVIN
  • 我是这项技术的新手。请帮我先生我该怎么办?@Ghasan
  • 我希望根据位置更改 URL。例如 Live Url practo.com/chennai/doctors/saidapet......

标签: javascript c# asp.net url url-rewriting


【解决方案1】:

希望您希望通过查询字符串传递多个参数并以该特定形式访问这些值。如果是这样,您必须像这样更改代码:

<a href="<%# String.Format("doctordetails.aspx?loc={0}&ID={1}&DoctorName={2}", Eval("Location"),Eval("DoctorID"),Eval("DoctorName")) %>"></a>

访问这些值的代码是:

Request.QueryString["Location"]; // Will give you the passed value for location
Request.QueryString["DoctorID"]; // Will give you the passed value for DoctorID
Request.QueryString["DoctorName"]; // Will give you the passed value for DoctorName

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2021-09-18
  • 2017-05-30
  • 2016-12-31
  • 2020-12-15
  • 2016-01-25
  • 1970-01-01
  • 1970-01-01
  • 2017-07-14
相关资源
最近更新 更多