Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
R

Ray Williams II

@Ray Williams II
About
Posts
14
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Custom WebForm inheritance issue (C#)
    R Ray Williams II

    I solved the problem myself but thought I would share the solution with the rest of the community. To restate the problem: The custom webform class that I created needed to accept property value changes for client-side manipulated hidden values, as well as server-side events. The first version of the code worked fine for client-side and onLoad events, but not for PostBack events. Original Codepublic bool Locked { get { object savedState; object clientState; try { if (Request.Params["__SmartWebFormLocked"].ToString().Trim() != "") { clientState = Request.Params["__SmartWebFormLocked"].ToString().Trim(); this.ViewState["__SmartWebFormLocked"] = clientState.ToString(); } } catch{} savedState = this.ViewState["__SmartWebFormLocked"]; if (savedState != null) return bool.Parse(savedState.ToString()); else return false; } set{this.ViewState["__SmartWebFormLocked"] = value;} }
    Modified Codeprivate string _Locked = ""; public bool Locked { get { if (_Locked != "") this.ViewState["__SmartWebFormLocked"] = bool.Parse(_Locked.ToString()); else { object savedState; object clientState; try { if (Request.Params["__SmartWebFormLocked"].ToString().Trim() != "") { clientState = Request.Params["__SmartWebFormLocked"].ToString().Trim(); this.ViewState["__SmartWebFormLocked"] = bool.Parse(clientState.ToString()); } } catch{} savedState = this.ViewState["__SmartWebFormLocked"]; if (savedState == null) this.ViewState["__SmartWebFormLocked"] = false; } return (bool)this.ViewState["__SmartWebFormLocked"]; } set { _Locked = value.ToString(); this.ViewState["__SmartWebFormLocked"] = value; } }
    With the updated code, server-side property value changes take priority of the stored or client-side property value. If no server-side event 'sets' the private string associated with the public property, then the get event returns either the client-side value from postback events or the viewstate value assigned to the property. Hope this helps someone

    ASP.NET csharp javascript design sysadmin tools

  • Custom WebForm inheritance issue (C#)
    R Ray Williams II

    I have created a custom webform class the implements some commonly used functionality that I use on most of my web pages. This webform class (SmartWebForm) is based on the System.Web.UI.Page class. Mainly it registers client script blocks and hidden fields based on properties set within the web form that inherits from it. The issue that I am experiencing pertains to the handling of the hidden fields. Within the base class I have implemented a ViewState/HiddenField combo for persisting client-side changes to values. Here is an example: Custom Property within SmartWebForm.cs Base Classpublic bool Locked { get { object savedState; object clientState; try { if (Request.Params["__SmartWebFormLocked"].ToString().Trim() != "") { clientState = Request.Params["__SmartWebFormLocked"].ToString().Trim(); this.ViewState["__SmartWebFormLocked"] = clientState.ToString(); } } catch{} savedState = this.ViewState["__SmartWebFormLocked"]; if (savedState != null) return bool.Parse(savedState.ToString()); else return false; } set{this.ViewState["__SmartWebFormLocked"] = value;} }
    OnPreRender Segment within SmartWebForm.cs base classprotected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (!Page.IsClientScriptBlockRegistered["SmartWebFormLockHandler"]) { .... CODE TO BUILD JAVASCRIPT .... Page.RegisterClientScriptBlock("SmartWebFormLockHandler",script.ToString()); } // Register Hidden Field to be Used by Client Javascript to control locking // mechanism from the client-side. Page.RegisterHiddenField("__SmartWebFormLocked",this.Locked.ToString()); }
    Here is where the issue occurs. I create a new WebForm, Page1.aspx, that inherits from by SmartWebForm Class. The [Locked] custom property defaults to "False" and is registered in the rendered page as:
    Within the code-behind for Page1.aspx, I add a server-side event to switch the [Locked] property from "False" to "True". This is done by setting the inherited base class property.private void SomeEvent() { this.Locked = true; }
    When the page is rendered however, the value recorded for the hidden field is stil

    ASP.NET csharp javascript design sysadmin tools

  • Help!! passing data from the form through page???
    R Ray Williams II

    ASP.NET TextBox Web Controls store their value in the Text property not the Value property. If the textbox controls are not available for processing in 2.aspx. You can push the values of the text boxes into Session variables and access them from any subsequent page (2.aspx, 3.aspx, etc.) In the postback event for 1.aspx, capture the values for your text controls and redirect. C#:

    Session["1aspx_txtName"] = txtName.Text;
    Session["1aspx_txtAddress"] = txtAddress.Text;
    Response.Redirect["2.aspx"];

    VB.NET:

    Session("1aspx_txtName") = txtName.Text
    Session("1aspx_txtAddress") = txtAddress.Text
    Response.Redirect("2.aspx")

    The session variables will be available for the extent of the users connection to the web site. Subsequent pages may access the values in the following manner. C#:

    String previousName = (String)Session["1aspx_txtName"];
    txtNewAddress.Text = (String)Session["1aspx_txtAddress"];

    VB.NET:

    Dim previousName as String = CType(Session("1aspx_txtName"),String)
    txtNewAddress.Text = CType(Session("1aspx_txtAddress"),String)

    You will want to limit the number of Session variables you create. They will take up memory on you server until unloaded when the users leaves the site.

    ASP.NET csharp help question

  • AutoPostBack
    R Ray Williams II

    Sorry, I'm not familiar with coding windows forms and web forms to work together.

    ASP.NET help question

  • Performing a query on a dataset object
    R Ray Williams II

    The most simple way would be to use a DataView object to filter the records found within the DataSet. The DataView may be bound to most data bindable objects including DataGrids, DropDownLists, Reports, etc. The DataView also allows for sorting and filtering. Filtering is enabled using the RowFilter property of the DataView. The row filter acts much like the where clause in a Sql statement. Assuming your DataSet object is named myDataSet and it contains a single Table named "Contacts". C#:

    DataView myDataView = (DataView)myDataSet.Tables["Contacts"].DefaultView;
    // or DataView myDataView = (DataView)myDataSet.Tables[0].DefaultView;
    String myFilter = "City = 'Chicago'";
    myDataView.RowFilter = myFilter;
    myDataGrid.DataSource = myDataView;
    myDataGrid.DataBind();

    VB.NET

    Dim myDataView as DataView = CType(myDataSet.Tables("Contacts").DefaultView, DataView)
    ' or Dim myDataView as DataView = CType(myDataSet.Tables(0).DefaultView, DataView)
    Dim myFilter as String = "City = 'Chicago'"
    myDataView.RowFilter = myFilter
    myDataGrid.DataSource = myDataView
    myDataGrid.DataBind()

    Using the DataView object does not modify the source DataSet, so subsequent filtering of the DataSet can be performed. To insure that I can retrieve the filtered recordset across postbacks, I usually create a ViewState variable to hold the row filter value and use the DataView object as the standard binding object for data when filtering is needed. C#:

    In the Page.OnLoad event...
    If !(Page.IsPostBack)
    {
    ViewState["myFilter"] = "";
    }
    In the filtering event...
    ViewState["myFilter"] = myNewFilterString;
    In the data binding event...
    String myFilter = (String)ViewState["myFilter"];
    myDataView.RowFilter = myFilter;

    VB.NET

    In the Page.OnLoad event...
    If Not Page.IsPostBack Then
    ViewState("myFilter") = ""
    End If
    In the filtering event...
    ViewState("myFilter") = myNewFilterString;
    In the data binding event...
    Dim myFilter as String = CType(ViewState("myFilter"),String)
    myDataView.RowFilter = myFilter

    ASP.NET database question csharp asp-net help

  • Help!! passing data from the form through page???
    R Ray Williams II

    Although I do not recommend this approach to coding in ASP.NET, you can use the Server.Transfer method to expose the sending page to the receiving page. Using this method can lead to some misleading results in your web browser. Specifically, the address bar in your web browser will still show the address of the sending page, even though the receiving page's content is being displayed. If possible, I would have the code-behind for the initial page handle the processing of its own data and redirect to subsequent pages as needed.

    ASP.NET csharp help question

  • AutoPostBack
    R Ray Williams II

    Are you scripting again the SelectedIndexChanged event for the individual dropdownlists? Although the AutoPostBack property is needed to tie the client-side event to the post back action, you will still need to capture the specific event which occured. Syntax varies between languages. So if you need more help, please provide your programming language.

    ASP.NET help question

  • web.cofig and authorization
    R Ray Williams II

    The asterisk will allow all athenticated users, and the question mark will allow all anonymous users.

    <authorization>
    <allow users="*,?"/>
    </authorization>

    ASP.NET csharp asp-net security question

  • Installation Project Problems
    R Ray Williams II

    Although I cannot be certain, you may want to check your permissions on the installer folder. If you are installing from a network, you may need to provide full control rights to the directory in order for the installation to complete. If you only have read access to the files, copy them locally and then run the installation. I found this information by doing a simple Google search.

    Visual Studio csharp visual-studio sysadmin help tutorial

  • Visual Studio.NET -&gt; ASP.NET problem
    R Ray Williams II

    You may have encountered a problem installing the ASP.NET ISAPI filters during your installation. You can complete you installation manually for a command prompt: Step 1: Select [Start], [Programs], [Microsoft Visual Studio .NET (or .NET 2003)], [Visual Studio .NET (or .NET 2003) Command Prompt] Step 2: Switch to your installation location... cd c:\windows\microsoft.net\framework [<-PRESS ENTER] Step 3: Run and directory to locate the directory for your current version of the .NET framework. You may have multiple version. I would select the most recent/highest version number. In my case, I would type cd v1.1.4322 [<-PRESS ENTER] Step 4: Enter the following command at the command prompt to register ASP.NET into your web server. aspnet_regiis -i When complete, you should be able to execute your sample application without additional coding.

    Visual Studio csharp asp-net visual-studio help

  • Report Document issue .NET 2003
    R Ray Williams II

    Make sure that your build of Crystal Reports 9 is compatible with Visual Studio 2003. CR 9 was released prior to the release of VS 2003 and there were some serious compatibility issues. I contacted CrystalDecisions about the same propblem and they provided an undated CD with the VS 2003 compatibility build. The CD's looked identical so don't assume yours is up to date. The version number that appears in my Crystal Reports designer [About] menu reads: Product Version: 9.2.2.693

    Visual Studio csharp dotnet visual-studio help question

  • CSS setting in datagrid
    R Ray Williams II

    Check the markup for your .CSS or Style section. The problem rests in your style sheet. Roughly stated, styles are defined based on three types: Tag, ID and Class. In your example;

    <style>
    ...

    GridHeader {
    vertical-align: baseline;
    font-size: 1em;
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
    }

    TD {
    font-size: 12px;
    font-weight: normal;
    word-spacing: normal;
    letter-spacing: normal;
    text-transform: none;
    font-family: Arial, Helvetica, sans-serif;
    }
    </style>

    you have defined [GridHeader] as a tag, which it is not. GridHeader should be defined as a class. Here is the corrected sytax.

    .GridHeader {
    vertical-align: baseline;
    font-size: 1em;
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
    }

    Note the classname is prefaced with a period (.). The period defines the scope of the style and allows the style to be applied to any number of elements on the page. This quick change should take care of the problems you are facing. UPDATE: Your markup for the style within the Datagrid does not change. You will still reference the style by its name only, without the period modifier.

    <headerStyle CssClass="GridHeader"/>

    ASP.NET css help question

  • CSS setting in datagrid
    R Ray Williams II

    Due to a flaw in the DataGrid control provided by Microsoft, it does not generate code compliant to the W3C standard. What this means for you and I is that table header's created by the DataGrid control will not render with <th/> tags. This flaw is documented on DataGrid Girl's website[^] and a fix has been posted to Microsoft support site[^]. Microsoft has not publicly released the fix, but provides a link to contact them for information. In the meantime... By renaming your TH style to "GridHeader" and adding the following line between your column tags, you will be able to impact the look of the header cells.

    <asp:boundcolumn, asp:templatecolumn, asp:ect...
    <HeaderStyle CssClass="GridHeader"/>
    </asp:boundcolumn, asp:templatecolumn, asp:ect...

    Unfortunately, this will not impact row level design elements.

    ASP.NET css help question

  • Can't get the anything from e.Item.Cells[1].Text
    R Ray Williams II

    You will need to access the DataBoundLiteralControl[^] in the same manner you have the LinkButton. The templated column is different from the bound column in that is implements the control collection for displaying its contents. In order to access the value of the templated column, you will need to evaluate the appropiate member of its control collection. =============== Sample DataGrid Code

    <asp:DataGrid ID="dgAdmin" Runat="server" DataKeyField="Id" AutoGenerateColumns="False">
    <Columns>
    <asp:BoundColumn DataField="Id" HeaderText="Id" />
    <asp:BoundColumn DataField="Value1" HeaderText="Value1" />
    <asp:BoundColumn DataField="Value2" HeaderText="Value2" />
    <asp:TemplateColumn HeaderText="Delete">
    <ItemTemplate>
    <asp:LinkButton ID="lnkDelete" Runat="server">Delete
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>

    =============== Event Code

    private void dgAdmin_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if (e.Item.ItemType != ListItemType.EditItem)
    {
    //## First, make sure we're NOT dealing with a Header or Footer row
    if (e.Item.ItemType != ListItemType.Header)
    {
    if (e.Item.ItemType != ListItemType.Footer)
    {
    //## Now, reference the LinkButton control that the Delete ButtonColumn has been rendered to
    System.Web.UI.WebControls.LinkButton deleteButton;
    deleteButton = (LinkButton)e.Item.FindControl("lnkDelete");

    			//## ADDITIONAL CODE
    			System.Web.UI.DataBoundLiteralControl templatedColumn;
    			templatedColumn = (DataBoundLiteralControl)e.Item.Cells\[2\].Controls\[0\];
    
    			//## We can now add the onclick event handler
    			//deleteButton.Attributes\["onclick"\] = "javascript:return confirm('Template Column: " + e.Item.Cells\[1\].Text + " | DataBound Column: " + e.Item.Cells\[2\].Text +"');";
    
    			//## MODIFIED CODE
    			deleteButton.Attributes\["onclick"\] = "javascript:return confirm('Template Column: " + e.Item.Cells\[1\].Text + " | DataBound Column: " + templatedColumn.Text +"');";
    		}
    	}
    }
    

    }

    ASP.NET csharp help asp-net graphics design
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups