简体   繁体   English

如何更改asp.net C#中的URL?

[英]how to change url in asp.net c#?

I'm trying to create search option in my ASP.net application to check Doctor details based on Location. 我正在尝试在ASP.net应用程序中创建搜索选项,以根据“位置”检查Doctor详细信息。 If I try the below code, only home page is showing. 如果我尝试以下代码,则仅显示主页。 http:www.example.com/doctordetails.aspx?ID=1/DoctorName=IVIN . http:www.example.com/doctordetails.aspx?ID=1/DoctorName=IVIN

I want the URL to be changed as per location. 我希望按位置更改URL。 Example expected URL: http://www.example.com/doctordetails/chennai/doctors/saidapet 预期的网址示例: http://www.example.com/doctordetails/chennai/doctors/saidapet : http://www.example.com/doctordetails/chennai/doctors/saidapet

I'm new to this technology. 我是这项技术的新手。

 <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>

Hope that you wanted to pass multiple params through query string and access those value in that particular form. 希望您希望通过查询字符串传递多个参数,并以该特定形式访问这些值。 if so you have to change the code like this: 如果是这样,您必须像这样更改代码:

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

And the code for accessing those values are : 访问这些值的代码是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM