ALTER PROCEDURE dbo.WebAdmin_BuildingTypeAdd
@NewBuildingType nvarchar(256),
@WasAdded int OUTPUT
AS
SET @WasAdded = 0;
-- Check to See If It Already Exists
DECLARE @BldgTypeExists int
SELECT @BldgTypeExists = BuildingTypeID FROM DataTypesBuilding WHERE BuildingType = @NewBuildingType
IF ( @BldgTypeExists IS NULL )
BEGIN
INSERT INTO [DataTypesBuilding] ([BuildingType]) VALUES (@NewBuildingType)
SET @WasAdded = 1
END
RETURN @WasAdded
My Popup:
<!-- ========== Popup for Adding a New Building Type ========== -->
<ajx:ModalPopupExtender ID="AddNewBuildingTypeExtender" runat="server" BackgroundCssClass="PopupBackground" PopupControlID="AddNewBuildingType" TargetControlID="IconAddBuildingType" CancelControlID="CloseBuildingType" />
<asp:Panel ID="AddNewBuildingType" runat="server" CssClass="Popup W600px" Style="display: none">
<div class="Inner" title="Add New Building Type">
<asp:Image ID="Image1" SkinID="PopupLogo" runat="server" ToolTip="My Service Solutions, Inc." />
<asp:Image ID="CloseBuildingType" runat="server" SkinID="PopupClose" />
<hr />
<h4>Add A New Building Type</h4>
<div class="Line">
<span class="Item">Market</span>
<asp:DropDownList ID="uiAddNewBuildingTypeMarket" runat="server">
<asp:ListItem Text="Commercial" Value="Commercial" />
<asp:ListItem Text="Industrial" Value="Industrial" />
<asp:ListItem Text="Residential" Value="Residential" />
</asp:DropDownList>
</div>
<div class="Line">
<span class="Item">Type</span>
<asp:TextBox ID="uiAddNewBuildingType" runat="server" />
<asp:RequiredFieldValidator ID="ReqFldInputAddNewBuildingType" runat="server" ControlToValidate="uiAddNewBuildingType" SetFocusOnError="true" Text="<img src='../../../ui/images/validate/WarningRequired.gif'>" ValidationGroup="ValGrpAddNewBldgType" />
<ajx:FilteredTextBoxExtender ID="FltrInputAddNewBuildingType" runat="server" SkinID="FilterNoCode" TargetControlID="uiAddNewBuildingType" />
</div>
<asp:Button ID="BtnAddNewBuildingType" runat="server" Text="ADD" CssClass="Button" OnClientClick="BtnAddNewBldgType_Click" ValidationGroup="ValGrpAddNewBldgType" />
</div>
</asp:Panel>
Top Of Page C# for receiving Viewstate
protected void Page_PreRender( object sender, EventArgs e )
{
viewBldgTypeAdded = (string)ViewState["viewBldgTypeAdded"];
viewNewBldgTypeAdded = (string)ViewState["viewNewBldgTypeAdded"];
if ( viewNewBldgTypeAdded == null )
{
viewNewBldgTypeAdded = "False";
ViewState["viewNewBldgTypeAdded"] = viewNewBldgTypeAdded;
}
if ( viewNewBldgTypeAdded == "True" )
{
StatusPopup.Show();
OutputStatusMessage.Text = "New Building Type Was Added: " + viewBldgTypeAdded;
}
if ( viewNewBldgTypeAdded == "False" )
{
StatusPopup.Show();
OutputStatus.Text = "Please Try Again!";
OutputStatusMessage.Text = "The Building Type " + viewBldgTypeAdded + " either already Exists, or is invalid";
ErrorMessage.Text="The Building Type " + viewBldgTypeAdded + " either already Exists, or is invalid";
}
}
So for OutputStatus Message all I get is "The Building Type either already exists or is invalid"
It is supposed to say "The Building Type Residential - Custom Home either already exists or is invalid" which is what I enter into the textbox.
since I do not get a record added, my guess is that no data is being accepted from the input controls, but I have no reason why it is not recognizing them.
and StatusPopup.Show() does not work - for another popup
"Success is the Sum of Small Efforts, Repeated Day in and Day Out - Without Ceasing!"
Currently Learning: ASP, SQL, CSS, JavaScript, AJAX, XML, XSLT, C# So please be patient with me! Thanks
I
noticedyourRequiredFieldValidator control. Due to the FilterTypes.Custom is default, you should provide alist of
validcharacters for ValidChars. for example: ValidChars="1234567890"
Besides,please use OnClick="BtnAddNewBldgType_Click" instead of
OnClientClick="BtnAddNewBldgType_Click" on the "ADD" button.
Bobby-Z
Contributor
2838 Points
1120 Posts
Several Issues On Page
Apr 24, 2012 03:41 AM|LINK
I have a dropdown list that if the item you need is not in there, an image icon opens a modalpopup so you can add it.
In my Popup I have two fields, one a dropdown, and one a textbox
I add the Value.ToString from the dropdown to the textbox so I get something like this "residential - custom home" or something similar
I record into db, then save in viewstate
Issue #1:
Nothing gets recorded. Upon update panel update, I get an empty field like there was no data entered into the textbox
Issue #2:
upon Update, My Status Popup does not show
protected void BtnAddNewBldgType_Click( object sender, EventArgs e ) { myConnection = new SqlConnection( Config.ConString ); myCommand = new SqlCommand(); myCommand.CommandType = CommandType.StoredProcedure; myCommand.CommandText = "WebAdmin_BuildingTypeAdd"; string myNewBldgType = uiAddNewBuildingTypeMarket.SelectedValue.ToString() + uiAddNewBuildingType.Text.Trim(); myCommand.Parameters.AddWithValue( "@NewBuildingType", myNewBldgType ); //SqlParameter vAdded = myCommand.Parameters.Add("@Return_Value", SqlDbType.Int); //vAdded.Direction = ParameterDirection.Output; //myCommand.Parameters.Add(vAdded); try { myConnection.Open(); myCommand.Connection = myConnection; myCommand.ExecuteNonQuery(); } catch ( SqlException SqlEx ) { Errors.SiteExceptionLog( "Sql", 0, SqlEx.ToString(), "AddNewBuildingType" ); } catch ( Exception Ex ) { // (ErrorType, PageID, ErrorMessage, SiteFunction) Errors.SiteExceptionLog( "Other", 0, Ex.ToString(), "AddNewBuildingType" ); } finally { myConnection.Close(); myConnection.Dispose(); } //myBuildingTypeWasAdded = Convert.ToInt32(vAdded.Value); ViewState["viewBldgTypeAdded"] = myNewBldgType; ViewState["viewNewBldgTypeAdded"] = "True"; }My Stored Procedure:
My Popup:
Top Of Page C# for receiving Viewstate
protected void Page_PreRender( object sender, EventArgs e ) { viewBldgTypeAdded = (string)ViewState["viewBldgTypeAdded"]; viewNewBldgTypeAdded = (string)ViewState["viewNewBldgTypeAdded"]; if ( viewNewBldgTypeAdded == null ) { viewNewBldgTypeAdded = "False"; ViewState["viewNewBldgTypeAdded"] = viewNewBldgTypeAdded; } if ( viewNewBldgTypeAdded == "True" ) { StatusPopup.Show(); OutputStatusMessage.Text = "New Building Type Was Added: " + viewBldgTypeAdded; } if ( viewNewBldgTypeAdded == "False" ) { StatusPopup.Show(); OutputStatus.Text = "Please Try Again!"; OutputStatusMessage.Text = "The Building Type " + viewBldgTypeAdded + " either already Exists, or is invalid"; ErrorMessage.Text="The Building Type " + viewBldgTypeAdded + " either already Exists, or is invalid"; } }So for OutputStatus Message all I get is "The Building Type either already exists or is invalid"
It is supposed to say "The Building Type Residential - Custom Home either already exists or is invalid" which is what I enter into the textbox.
since I do not get a record added, my guess is that no data is being accepted from the input controls, but I have no reason why it is not recognizing them.
and StatusPopup.Show() does not work - for another popup
Currently Learning: ASP, SQL, CSS, JavaScript, AJAX, XML, XSLT, C# So please be patient with me! Thanks
YunJiang
Participant
1124 Points
122 Posts
Re: Several Issues On Page
May 01, 2012 01:35 PM|LINK
Hi,
I noticed your RequiredFieldValidator control. Due to the FilterTypes.Custom is default, you should provide a list of valid characters for ValidChars. for example: ValidChars="1234567890"
Besides,please use OnClick="BtnAddNewBldgType_Click" instead of OnClientClick="BtnAddNewBldgType_Click" on the "ADD" button.