VS 2012 - Get ID Of Inserted Row

Sep 5, 2012

How I would get the ID of the row that was inserted using the following? (VS2012 VB.NET)

Code:
Dim connString = ConfigurationManager.ConnectionStrings("DBConnectionString").ToString
Dim conn As New SqlConnection(connString)

[code]....

View 1 Replies


Similar Messages:

VS 2012 - Creating Layout Using CSS

Jun 23, 2014

I need to create below layout using Div's. i should not use table to create this. also i need to do this with css and I have to use % for width and height. Any sample code. on the below image left border is missing. But I want that as well.

View 4 Replies

VS 2012 - String URL Parameters In MVC 4

Jul 10, 2014

I have the following code:

HTML Code:
<html>
<head>
<script type="text/javascript" src="~/Scripts/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

[Code] .....

This code works fine for populating a div with html from a view. Where I'm having trouble is figuring out how to pass a string parameter to my view, so as to customize what the view returns. Passing a number doesn't seem to be a problem, but I can't get the string right. I need to know:

1. how to format the string in the url - or even if passing the string in url is right.
2. how to structure the route in routeConfig.

View 5 Replies

VS 2012 - Can Do A Post From GridView?

Jun 4, 2013

I have a gridview on a page where I display a list of items. One of the columns on the gridview is a hyperlink that sends a querystring to another page, which then displays the details of the selected item. It's your basic CRUD operation and it works great except for one thing: The query string has some information in it that I'd rather not be public. Is it possible to have a link or a button or some other sort of column that does a post to the new page instead of a querystring?

View 29 Replies

VS 2012 / Best Way To Produce A Percentage Bar?

Dec 2, 2013

I need to produce a simple graphic which is a simple rectangle (bar) with a variable portion filled in to denote a percentage.

What is the best way to achieve this? I had a look at the .net charting tools but the nearest I could find to what I needed was the barchart which didn't quite seem to meet my needs for a single value.

View 1 Replies

VS 2012 - Not Getting Value From DropdownList On RowUpdating Event

Jul 10, 2013

I have a gridview that has 3 dropdowns. And when I am in edit mode, when updating via the RowUpdating event, I am not getting a value from my 2nd or 3rd drop downlists. Here's the code from RowUpdating:

Code:
Protected Sub gridOutdoor_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
'WHEN DEBBUGING, the text for ddBodyColor.Text is an empty string. I had selected a value prior to this event firing."
Dim ddBodyColor As DropDownList = DirectCast(gridOutdoor.Rows(e.RowIndex).FindControl("ddBodyColor"), DropDownList)
End Sub

Here's the source code for ddBodyColor:

Code:
<EditItemTemplate>
<asp:DropDownList ID="ddBodyColor" runat="server" TabIndex="2" AppendDataBoundItems="true" Enabled="true" DataTextField="bodyColor" DataValueField="bodyColor"><asp:ListItem Text="Select" Value="" /></asp:DropDownList>
</EditItemTemplate>

View 9 Replies

VS 2012 - How To Create Datetime Parameter

May 30, 2013

I have a form and I want to insert the current time at which the user clicks to insert into the table of my db.
When running, I get the following error when trying to insert into my sqldatasource:

"System.FormatException: String was not recognized as a valid DateTime."

What's wrong with my insert parameter?:

<InsertParameters>
<asp:Parameter Name="DateAdded" Type="DateTime" DefaultValue= "<% DateTime.Now %>" />
</InsertParameters>

View 6 Replies

VS 2012 - Get Checkbox Checked Value In DetailsView

Dec 30, 2015

I have created a single checkbox in the DetailsView of my Asp page. I then created VB code behind to set the value =1 if the checkbox is checked and value =0 if checkbox is not checked. I cannot get the code to work. The record will get created in my SQL database, but the checkbox field remains NULL

In SQL table, my field and datatype is: Greenfield, bit, NULL

The beginning code for DetailsView1 is:

Code:
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White" BorderColor="White" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataKeyNames="ID" DataSourceID="tblEntryFormDS" style="text-align: left; margin-bottom: 0px;" Font-Bold="False" Font-Names="Arial" Font-Size="Small" DefaultMode="Insert" GridLines="Horizontal" CssClass="auto-style47">
<AlternatingRowStyle BorderStyle="None" />

The code for the checkbox within DetailsView1:

Code:
<asp:CheckBox ID="CheckBox1" runat="server" Text=" Greenfield" AutoPostBack="True" />

And the VB code behind. I originally used OnCheckedChanged but that wasnt working and it was suggested of me to use DetailsView1_ItemInserting instead: (The Dropdownlists in the code are working)

Code:
Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles DetailsView1.ItemInserting
Dim DropDownList6 As DropDownList = CType(DetailsView1.FindControl("DropDownList6"), DropDownList)
Dim DropDownlist9 As DropDownList = CType(DetailsView1.FindControl("DropDownList9"), DropDownList)

[Code] ....

View 1 Replies

VS 2012 - Webrequest Authentication 401 Unauthorized

May 1, 2015

I'm trying to connected to a third-party server, that allows API access via XML post/response. I've created just a very simple test page with a button to press.... the button should just go to the URL, log in with basic authentication and then return the response. if I use a browser and go to the URL, I see the XML response. Usuing my app, I'm still getting 401 unauthorized. I've been at this for hours, I've searched the forums and googled extensively, still no luck. Also, this is an internal app to internal server so security is not the highest priority. I'm setting the UN and PWD for authentication in a simple form.

Here's my VB code behind:

Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
Dim result As String
'disables self-signed SSL cert errors

[Code] ....

And the username and password are 100% accurate - as I mentioned above the code (well, implied).

I feel like this SHOULD be pretty easy: Overall request for testing: Submit a web request to a URL, disable the SSL check (self-signed certs used), login with basic UN and PWD I supply, return the response to a textbox.

View 1 Replies

VS 2012 - Class Is Not Returning Object

Feb 11, 2014

I have a class TicketOrder. It's not recognizing my lstSectionNumber (Tickets.TicketForm.lastSectionNumber is inaccessible due to its protection level).

Here is the code for TicketOrder class:

public class TicketOrder
{
public TicketOrder(TicketForm form)
{
this.form = form;
}
//Declare static variables

[Code] .....

This is my code behind:

public partial class TicketForm : System.Web.UI.Page
{
//Declare variables
int myInt;
TicketUser user = new TicketUser();
TicketOrder order;

[Code] .....

View 3 Replies

VS 2012 - Update Button In Gridview

Sep 30, 2013

I have a web app and one of the forms has a gridview and also two tables.

Because of this, I have a save button that saves new data; and I also have update buttons that appear each time the user clicks Edit in a row of the gridview.

I would like to see if there's a way to combine my save with my update so that the user only has to click one time to save.

I was looking for the update button link that appears in my gridview via the source code page, but it's no where to be found.

Is there a way to move the update button or not show it? Not sure how to even start using the save to incorporate both.

View 2 Replies

VS 2012 - Set BGColor Based On SQLDatasources

May 7, 2013

How to set the bgcolor of an asp.net cell from code behind using a value from a sqldatasource?

I have a working sql data source that is used to populate labels in my html form using asp.net.

The background color of the cell depends on a comparison of the actual value versus the target value. If the actual daily value exceeds the limit I would like to change the bgcolor of a cell in the web page. The actual value comes from one datasource and the limit comes from a 2nd data source.

In vb code behind I would like to accomplish the following pseudo code:

If (sqlsource1Total > sqlsource2Limit) Then
bgXCell.BgColor = "#ccff99"
Else
bgXCell.BgColor = "#ff9999"
End If

View 3 Replies

VS 2012 - Get Data In Code-behind From ListView

Jul 16, 2015

how I can get item values in a ListView in code-behind? I’ve searched high and low during the past 2 days and tried various possibilities to no avail. Data binding is being done in code-behind:

Code:
SQLString = "SELECT Field1, Field2, Field3 FROM Table1"
DataTable1 = LoadDataTable(Connection1, "SELECT Field1, Field2, Field3 FROM Table1")
ListView1.DataSource = DataTable1
ListView1.DataBind()
ASP:

[code]....

The aim is that once a user clicks on a particular row in the ListView a pop-up is displayed which in turn reflects all data related to the record. For the purpose of preparing the data for the pop-up I need to determine the unique record identifier.

I have the same code working perfectly in another app, which has to effect that once a user clicks on a particular row in the ListView a new tab is opened which in turn reflects all data related to the record.

View 1 Replies

VS 2012 - How To Handle Ajax Requests In MVC

Jun 24, 2014

This is sort of a continuation of a previous thread: View thread

The requirement I have is to be able to have a popup form that shows detailed data on a facility. This would be available on various pages of the website where the user may want to drill down and see detailed information on a facility. We also want to allow the user to update the data on the facility if so desired. I have the code working to show the popup form and get the html for the popup from a view. Right now I'm setting the values of the input boxes using razor code that accesses the @model object. That's about as far as I've gotten.

Where I'm struggling is:

1. How to tie the data in the inputs back to the view model.
2. How to write the ajax code to write the data back to the server. I tried using a standard form, but that redirects the original page that popped up the form. I want to leave that page alone and just submit the data back to the server and close the popup.

Now my dev lead wants us to use the dojo toolkit for our javascript library. That would be OK if I already knew what I was doing with regard to web development, but I don't - and documentation is just not very good with regard to dojo. I'm still trying to figure out html and mvc, so I thought I'd see if I can get this scheme working with some other javascript library first, and then see about switching it over to dojo.

I've read some about knockout and jquery, but with everything being so new to me it's hard to get all this to gel in my head, and I'm not sure about my design. I've read some about mvc's built in ajax tools, but so far all I'm seeing is stuff related to getting data and displaying it - not about submitting data.

I'd like to be able to send the data back to the server in the same object structure that I extracted it with - something that matches the model. I think this is doable, but I'm not sure - and the 'how' of it is escaping me at this point.

View 20 Replies

VS 2012 / Create A Function For Web Method That Is In DLL?

Jul 6, 2015

I want to create a function that a web method will call - and that function will be in a DLL.

I am assuming that having that function in a DLL is better then leaving it as source since it won't recompile when IIS recycles or whatever schedule that falls under.

Do I need to make this function in a different project (solution) and compile it down to a DLL and then refer to that folder location in the WEB.CONFIG?

And I assume I just put it in the BIN folder in INETPUB - right? Do I need a WEB.CONFIG reference to it as well - in production?

View 9 Replies

VS 2012 - Confirmation Dialog In UpdatePanel

Aug 20, 2014

A user inserts ad details and on button click saves them to database. If the save is successful, a DIV element slides down (becomes visible) allowing the users to add pictures for that ad.

As the users adds the pictures, they are being shown in a Repeater control. When you hover over a picture, a Delete button is displayed and when you click it, a confirmation message pops out asking the users if they really want to delete the picture.

Now this is where the problems begins. The code behind the button click doesn't wait for the user to click YES or NO. It just executes leaving the message displayed.

So to summarize:

- The entire "bottomDIV" element is wrapped inside an UpdatePanel with update mode set to "Conditional".
- Since the Button is inside the Repeater control, I cannot access its Click event. I use Repeaters ItemCommand to check for the correct Command Name.
- The Repeater Control is inside the same UpdatePanel
- The Update Panel has AsyncPostBackTrigger set to Repeater Control.

The HTML:

HTML Code:
<asp:UpdatePanel ID ="bottomUpdate" runat ="server" UpdateMode="Conditional" >
                         <ContentTemplate>
                        <div id ="bottomWraper">
                        <div id ="savePictureWraper" runat ="server" style="float:left; padding-top:3px;" >
                         <asp:TextBox ID ="pictureName" runat ="server" placeholder ="Naziv slike" style="width:181px;">
[Code] ....

The Script (using alertify.js to display the confirmation dialog):

HTML Code:
<script>           
        $("[id*=btnDeletePicture]").on("click", function () {
                alertify.confirm("Confirm?", function (e) {
                    if (e) {
                        alertify.alert("Successful AJAX after OK");
             
[Code] ....

The code behind is simple and all it does it executes the delete statement and then calls the displayPictures sub again. So, why the code behind doesn't wait for the user to select an option in confirmation dialog....

View 1 Replies

CR And VS 2012 - Type Or Namespace Name Could Not Be Found

Jul 30, 2014

I have error in vs 2012

The type or namespace name 'CrystalDecisions' could not be found (are you missing a using directive or an assembly reference?)

Error 18 The type or namespace name 'ReportDocument' could not be found (are you missing a using directive or an assembly reference?)

View 1 Replies

VS 2012 - Code In Source Keeps Jumbling All Up

Aug 14, 2013

I am creating a web app using vs 2012. I am constantly having re-arrange my code because, each time I either scroll or move off the page, I go back and it's all jumbled up again. E.g.

<table><tr><td></td></tr></table> 'fixed nicely

scroll or move off the page:

<table> <tr>
<td>
</td></tr>
</table>

Is this just the way it is...or is there a way to fix it so it stays as how I put it?

View 3 Replies

VS 2012 - TreeView Cause Page Load Twice?

Jun 9, 2015

I use a Treeview control like below code.. it cause page_load event twice.. how to stop page_load firing twice?

HTML Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="AdminSection_test" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">

[Code] ....

View 16 Replies

VS 2012 - Creating Web Form With Specific Names

Aug 1, 2013

I created tracking software, and now I need to create hundreds of web forms with specific names (within the same solution). Can this be accomplished with managed code or does it all have to be done manually? In case you are wondering what this is for - its to do market research using the keywords in unique URLs...so I just need to be able to create hundreds of them at once to hand to my classified ad poster.

View 2 Replies

VS 2012 - Loading Images Into Repeater Control

Aug 19, 2013

I'm creating a simple CMS for a fairly simple web page. I'm currently working on a part for displaying news on the main page.

The controls I have on the page:

- a GridView control with enabled pagging and a SELECT button,
- an Image control for displaying news cover picture,
- CKeditor control for editing news text,
- Repeater control for displaying pictures from database

How does it all work?

In Page_load I have the following:

vb.net Code:
connectionString = "Data Source=KORISNIK-PCSQLEXPRESS;Initial Catalog=****;
User ID=**;Password=****"        conn = New SqlConnection(connectionString)       
If conn.State = ConnectionState.Closed Or conn.State = ConnectionState.Broken Then             
Try                conn.Open()                If Not IsPostBack Then                    bindGrid()                   

[Code] ...

As you can see, I load the GridView control with news from DB. At this moment all other control are disabled. User has to SELECT the row he wants to edit, and click the MODIFY button.

This is what happens when user clicks the MODIFY button:

vb.net Code:
Private Function selectForEdit()        dsSelectForEdit = New DataSet       
captionPicture.ImageUrl = ""         enableCommands()       
Dim sqlQuery As String        
sqlQuery = "SELECT news.newsCaption, news.newsIntro, news.newsCoverPicture, news.newsStatus,

[Code] ....

Basically, I select newsDetails based on newsID. Also, this is where I take the coverPicture from the database using a generic handler.

This is the code for showImage.ashx:

vb.net Code:
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest        
Dim newsID As Int32        If Not context.Request.QueryString("newsID") Is Nothing Then           
newsID = Convert.ToInt32(context.Request.QueryString("newsID"))        Else           
Throw New ArgumentException("No parameter specified")        End If        

[Code] ....

This part works fine, as the picture is correctly displayed in the Image control. Now, I also want to load the pictures that are related to the selected news. So, I use this function:

vb.net Code:
Private Function selectNewsPictures()        dsSelectPicturesForEdit = New DataSet         enableCommands()       
Dim sqlQuery As String         sqlQuery = "SELECT newsDetailsPictureID,newsDetailsPicture,newsDetailsPictureCaption,newsDetailsPictureDescription FROM newsDetailsPictures WHERE newsID = @newsIDEditing"          myCommand = New SqlCommand(sqlQuery, conn)         myCommand.Parameters.Add("@newsIDEditing", SqlDbType.Int, 250)       

[Code] ....

You can see that I take pictureID's and store them into a List (of integer). That way I can use those integers in showNewsPictures.ashx to display all the pictures.

showNewsPictures.ashx:

vb.net Code:
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest        
Dim newsID As Int32        If Not context.Request.QueryString("pictureID") Is Nothing Then           
newsID = Convert.ToInt32(context.Request.QueryString("pictureID"))        Else           
Throw New ArgumentException("No parameter specified")        End If        

[Code] ....

The picture ID's are being sent through pictureRepeater_ItemDataBound:

vb.net Code:
Private Sub pictureRepeater_ItemDataBound(sender As Object, e As RepeaterItemEventArgs)
Handles pictureRepeater.ItemDataBound        
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then            
Dim ctrl As New Image            ctrl = e.Item.FindControl("pictureHolder")           
ctrl.Width = 100            ctrl.Height = 100              ctrl.ImageUrl = "~/showNewsPictures.ashx?pictureID=" &
listOfIDs.Item(itemIndex)            itemIndex = itemIndex + 1         End If    End Sub

THE PROBLEM:

I load the page, select the news, click the MODIFY button and all works well. The news details are loaded, the cover picture is loaded, the repeater pictures are loaded.

I click the cancel button (clears all the commands and disables them) and I get an error saying the DataReader needs to be closed.And I never use one This happens either in showNewsPictures.ashx or showImage.ashx.

In some other scenario, this happens right after I click the MODIFY button.

View 1 Replies

VWD 2012 (Show Table Data) Missing

Aug 16, 2012

When i right click on a table in database explorer i do not get the option to "show table data" the way i have in every other previous version.

View 2 Replies

Web Form Survey - Showing New Page (VB 2012)

Mar 18, 2013

I have VSExpress 2012 and am creating a WebForm survey app.

I have two pages - the start page (StimEntry.aspx) and the survey page (SurveyPage.aspx)

I have a "Begin Survey" button on the StimEntry page, but am not sure how to switch the user to the survey page when they click that button. Desktop app tutorials use PAGE.show, but that doesn't work here, and I'm assuming that's because I am working in a web form, but am not sure about that.

View 2 Replies

VS 2012 AJAX - Updating IFrame Correctly

Jan 24, 2014

I have a page with an updatepanel, which at runtime has controls dynamically created. The controls are saved within the cache, and readded to the page upon postback each time when needed. Sometimes the controls need to change, sometimes not. In most of my cases, if I just re-add the control to the page without any changes to the control AJAX will leave the control alone on the client-side leaving me with what I expect to see, which is no change. If I make a change, it obviously updates correctly.

Now, I have added a literal control which defines an iFrame which points to another page. ie:

Code:
.LiteralControl.Text = "<iframe name='" & .LiteralControl.ID & "' id='" & .LiteralControl.ClientID & "' frameborder='no' scrolling='auto' height='" & _
.ItemHeight & "px' width='" & .ItemWidth & "px' src='" & "WBRender.aspx?ViewID=" & strUniqueID.ToString & "' style='position: absolute; " & _
"left:" & .ItemLeft & "px; top:" & .ItemTop & "px;'></iframe>"

If I re-add this control on postback, with a change, I get the item on the page as I expect. If I make no changes to the .Text and simply re-add the control to the page, it flashes as though it has been changed and then re-requests the page defined by the src. The whole point of me caching this, is to stop the client-side from updating a control that has not changed, removing a flashing screen and all the resizing that goes with it.

View 1 Replies

VS 2012 - Setting Virtual Path In Website

Oct 26, 2013

I have a website solution where I have among other things some code for a photo album. I know wanted to make a separate website solution with only the photoalbum code. It is however giving me some issues with not finding files, which I believe are caused by not being able to set the virtual path in the website solution. The option is simply not present in the options as you can see on the image on the right.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved