簡體   English   中英

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

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

我正在嘗試在ASP.net應用程序中創建搜索選項,以根據“位置”檢查Doctor詳細信息。 如果我嘗試以下代碼,則僅顯示主頁。 http:www.example.com/doctordetails.aspx?ID=1/DoctorName=IVIN

我希望按位置更改URL。 預期的網址示例: http://www.example.com/doctordetails/chennai/doctors/saidapet : 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>

希望您希望通過查詢字符串傳遞多個參數,並以該特定形式訪問這些值。 如果是這樣,您必須像這樣更改代碼:

<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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM