.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

passing querystring

Posted By:      Posted Date: October 16, 2010    Points: 0   Category :ASP.Net

Hello i have a page, when the page loads, nothing shows up, when i pass the querystring on the browser as this:http://localhost:51765/livingtopleasegodworld/PhotoAlbum.aspx?ID=c516f4f4-36a9-40a7-baad-d2419ea631b9

it works. Can someone help me with this? I want it to work when the page load not when i pass the querystring on the browser.

Here is the code:


SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId) ORDER BY [Name]"> 
<asp:QueryStringParameter Name="UserId" QueryStringField="ID" /> 
Filter Pictures By

View Complete Post

More Related Resource Links

Passing Id to a querystring in a Listview Control

I have tried almost evrything and nothing seems to work,,, I dont see errors but the code is not firing when I bind in the properties of the button control ,,nor the code behind., much help is appreciated,,aspx<LayoutTemplate>                <table id="Table1"cellpadding="0" cellspacing="0" style="border-right: #000000 thin solid; border-top: #000000 thin solid;                                    border-left: #000000 thin solid; border-bottom: #000000 thin solid; background-color: #FFFFFF; border-width: 1px;"                                    width="100%" align="center">        <tr>            <td>                    <b>Matching Providers </b>        

Passing Querystring Value into Gridview/Listview

I have a master-detail page consisting of a databound GridView and ListView. It's pretty standard - when you select a row in the GridView is shows up the ListView. The problem I'm running into is when I want to link to that page with a specific row pre-selected in both views. It seems like it should be easy enough, but I just can't figure it out. Currently, the ListView is connected to the GridView with a ControlParameter in the SelectCommand. Any assistance would be greatly appreciated. (Let me know if you need more info.)

passing guid value in querystring issue


trying to pass a guid value to querystring - it should take the guid value from one page to another. i get an error: value cannot be null, parameter name: g. so my guid value is not being pass to my second page. below is code:

Page one:

        static Guid g = Guid.Empty;

        public static string userID = g.ToString();
        string userName = string.Empty;

        protected void Page_PreInit(object sender, EventArgs e)
            MembershipUser mu = Membership.GetUser();
            if (Membership.GetUser() != null)
                userName = mu.UserName.ToString();
                userID = mu.ProviderUserKey.ToString();


Ajax cascading dropdown and passing querystring to webservice



i am using Cascading dropdown, with following scenario.

a page "myPage.aspx" is loaded with a Querystring. [http://localhost/myVD/myPage.aspx?jobID=003]

this page contains 2 cascading dropdowns say state & City .  the idea is to fill the provinces Combo based on INCOMING querystring value "jobid".

also i have a webservice named "Mywebservice.asmx" which has webmethods to retrieve city based on jobID.

but since these webmethods are Contained in asmx . the querystring of the caller page is not visible to the webmetod of the service.

here's  snippet for reference/

public CascadingDropDownNameValue[] GetContainerByJobID(string knownCategoryValues, string category
            //StringDictionary categoryValues = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            //string jobId  = categoryValues["JobID"];

           string  jobId

Having Problems Passing A Querystring


I have a page called: TreatmentBrowse.aspx which has a GridView on it showing a name and description. The name is a Hyperlink and the DataNavigateURLFormat is set to: TreatmentMaintenance.aspx?treatmentId={0}. So if they click a name it goes to a TreatmentMaintenance and loads the name and description in the DataView with the records from the TreatmentBrowse.aspx. My problem is every time I click a hyperlink, no matter what one it always shows me the information for ID 1. How can I fix this to show me all data corresponding the the hyperlink treatmentId?

Thank You

Passing Linq Statement between master and content page


I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub

On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If

m.searchRes is always nothing. 

What am I doing wrong here?


Passing values in pages


Hi! Friends..

how to pass the value from one page to another page in asp.net  with out Using State Management Concepts?

Like 1. cookies


        3. QueryStrings

     With out using the above should pass the values...

Arabic QueryString with Url Rewrite Solution


Alsalamo 3alaykom ,

as we know that if you use Intelligencia.UrlRewriter.RewriterHttpModule or IIS URL Rewriting , we will face problems with arabic urls

as this

http://localhost:1234/Pages/???? ?????? ?????? ??????????

and the Rule is :

<rewrite url="~/Pages/(.+)" to="~/ShowPages.aspx?Page=$1" />

you will recive the QueryString["Page"] Like this

نائب العميد للشؤون الأكاديمية

so it's a big problem , and there is a solution that is :

remove the Rule of that rewriting ,,

<rewrite url="~/Pages/(.+)" to="~/ShowPages.aspx?Page=$1" />

then open your Global.asax file and Application_BeginRequest method exactly

use the following code to handle you request

void Application_BeginRequest(object sender, EventArgs e)
if (HttpContext.Current.Request.Url.ToString().Contains("/Pages/"))
	String[] txt= Regex.Split(HttpContext.Current.Request.Url.ToString(), @"/");
	String page = txt[txt.Length-1];

Passing Data to a Cell in Excel



I have a webpage that is created in Visual Studio 2008 and programmed in C#.

I have a web form that prompts the user to enter a value into a text box.  For now, I do not have any validation on that field (I will be adding that later).

I need to pass the value that the user has entered to cell C1 of the excel spreadsheet (user_info.xls).

I understand that using excel is not ideal, but unforutnately need to try to make this work with the excel spreadsheet.

I do not have any code for this yet, because I honestly do not know how to begin.

The action of poulating the excel spreadsheet will be intialized from the On Click event of a Submit button.

Any suggestions would be much appreciated.

Thank you in advance for your assistance,


Passing HTML values from asp.net to asp


 We have a part of our website which is coded in classic asp. This takes the values of a login page (asp.net)  which uses 

<input type="text" /> to hold the values and then submit them to the asp page using the following line of code -

<input type="submit" value="Login" onClick="this.form.action='<%= SubmitURL() %>/login/login_user.asp?Type=Login&amp;this.form.encoding='application/x-www-form-urlencoded'; this.form.submit();" />

The asp page then retrieves the values using the code -

Value1 = Request.Form("Val1")

We now have a requirement to pre-populate the login values to provide an automated login process but don't want to change the older asp code. When we try to assign values to the input text in the asp.net page by assigning the value runat="server" the login fails as it does not seem to carry over when the page is submitted.

Is there a way where we can pre-populate the html textbox without making it unavailable to the asp page?


passing page title through a param


Hello all,

   I am new to ASP.NET, and was wondering how to pass a Page title through a parameter.  In classic ASP I could just use something like: <title><%=Pagetitle%></title> but I cannot seem to get this to work in ASP.NET. 

Thank you in advance,

The New Guy... Smile 

Passing Primary Key to User Control to Display Record Detail


I'm building a user control to display detail information on a parent record. The user control will be displayed via an Ajax Modal Popup. The user control works and is displayed when expected. The problem that I'm having is that I'm not able to pass in the primary key for the parent. The control is displayed via the _ItemCommand event of a Repeater. In the markup for the user control, I explicity set the ContactId to 0 to avoid an error when the control loads (its still underdevelopment, eventually that I'll check if the value is valid).

I was assuming that I could change the property in the _ItemCommand event, but obviously its not working.

In the Page_Load event this code successfully sets the ContactId property of the control. The _ItemCommand event appears to set the value. However when I set a test label on the user control to the Me.ContactId, its showing '0' as if it was never passed in.

        UserControlContactDetail.ContactId = "1462"
        test.Text = UserControlContactDetail.ContactId

    Protected Sub RepeaterDirectory_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles RepeaterDirectory.ItemCommand

Protected Sub RepeaterDirectory_ItemCommand(By

file not passing to controller


 I am getting an null referance on file, what am I doing wrong. 

<% Html.EnableClientValidation(); %>
<% Html.BeginForm("AddMedia", "Pattern", new { id= Model.Pattern_Guid} , FormMethod.Post, new {enctype = "multipart/form-data"}); %>
<%: Html.ValidationSummary(true) %>
    <%: Html.Label("height") %>
    <%: Html.TextBox("height") %>

    <%: Html.Label("width") %>
    <%: Html.TextBox("width") %>

    <%: Html.Label("Media") %>
    <input type="file" id="Media" name="Media" />
    <input type="submit" name="btnAdd" value="Add" />
<% Html.EndForm(); %>

controller code:

        public ActionResult AddMedia(Guid id, HttpPostedFileBase file, FormCollection collection)
            string mimeType = file.ContentType; //  Null Exception here ..

Passing Parameters through sub reports



I am trying to use a parameter field where there is a subreport in my main report but i keep getting the error "subreport cannot be shown" when running the report. Any ideas please.

p.s - I have just set the parameters the same in the subreport as the main report.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend